Это решение, которое я нашел для кода.
publi c class MaxOfNnumbers {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader (System.in));
System.out.println ("Enter the amount of numbers to be scanned");
// if we enter n to be 0 or negative , we cant form an array
// hence an if condition where if(n > 0) is applied before forming
// the array .
int n = Integer.parseInt ( reader.readLine () );
System.out.println ( "Entered value for n is "+n );
int leastNum[] = new int[n];
System.out.println ("Array size is "+leastNum);
// for reading the data from keyboard least num array is declared
// this array is fed from the keyboard .
if(n > 0){
for(int i = 0; i < n ; i++){
leastNum[i]=Integer.parseInt ( reader.readLine () );
System.out.println ("Value stored at "+ i+ "Location is"+leastNum[i]);
}
System.out.println ("Least num length is "+leastNum.length);
int maximum = Integer.MIN_VALUE;
System.out.println («начальное значение максимума равно» + максимум);
for(int i =0 ; i < n; i++){
if(maximum < leastNum[i]){
maximum = leastNum[i];
}
}
System.out.println(maximum);
}
}
}