Getting the largest element in an array using recursion Any suggestions on how to make this code more efficient?

import java.util.Scanner;
public class RecursionLargestInArray 
{ 
public static void main (String[] args) 
{ 
    int max = -999; 
    Scanner scan = new Scanner (System.in); 
    System.out.print("Enter the size of the array: "); 
    int arraySize = scan.nextInt(); 
    int[] myArray = new int[arraySize]; 
    System.out.print("Enter the " + arraySize + " values of the array: "); 
    for (int i = 0; i &lt; myArray.length; i++) 
        myArray[i] = scan.nextInt(); 
    for (int i = 0; i &lt; myArray.length; i++) 
        System.out.println(myArray[i]); 
    System.out.println("In the array entered, the larget value is " 
                        + getLargest(myArray, max) + "."); 
} 

public static int getLargest(int[] myArray, int max) 
{     
    int i = 0, j = 0, tempmax = 0; 
    if (myArray.length == 1) 
    { 
        return myArray[0] &gt; max ? myArray[0] : max; 
    } 
    else if (max &lt; myArray[i]) 
    { 
        max = myArray[i]; 
        int[] tempArray = new int[myArray.length-1]; 
        for (i = 1; i &lt; myArray.length; i++) 
        { 
            tempArray[j] = myArray[i]; 
            j++; 
        } 
        tempmax = getLargest(tempArray, max); 
        return tempmax; 
    } 
    else
    { 
        int[] tempArray = new int[myArray.length-1]; 
        for (i = 1; i &lt; myArray.length; i++) 
        { 
            tempArray[j] = myArray[i]; 
            j++; 
        } 
        tempmax = getLargest(tempArray, max); 
        return tempmax; 
    } 
} 
}
I would use a helper function, and I would avoid copying the array (using indices instead):

public static int getLargest(int ... myArray) {
    return getLargest(myArray, 0, myArray.length);
}

private static int getLargest(int[] myArray, int from, int to) {
    if(from == to) {
        throw new IllegalArgumentException("empty array");
    } else if (from + 1 == to) {
        return myArray[from];
    } else {
        int middle = (from + to)  / 2;
        return Math.max(getLargest(myArray, from, middle),
                        getLargest(myArray, middle, to));
    }
}


Using varargs int ... instead of an array int[] for the argument makes it more flexible, e.g. better testable.

In case you really want to copy the array, use System.arraycopy, which is much faster than looping through.