import java.util.*; public class MaxElement { public static void main(String[] args) { // creating array lenght of 5 integers, and receving input from keyboard int[] a = new int[5]; Scanner tastatura = new Scanner(System.in); System.out.println("Type elements of array ... "); for (int i = 0; i < a.length; i++) { System.out.print("Type " + (i+1) + ". element: "); a[i] = tastatura.nextInt(); } //printing max element of array System.out.print("Max element of array is: "); System.out.println(a[max(a)]); } public static int max(int[] a) { int n = a.length; if (n == 1) return 0; else { int i = max(Arrays.copyOf(a,n-1));//this is a problem... i dont know what is returned to int i? if (a[i] < a[n-1]) return n-1; else return i; } } }