i entered value in (system.in) both in vertical manner and horizontal manner and then click the run button, error and if i click without entering value, even then the same error..
public static void main(String[] args) throws Exception {
int[] array = initializeArray();
int max = max(array);
System.out.println(max);
}
public static int[] initializeArray() throws IOException {
// Create and populate the array
BufferedReader b = new BufferedReader(InputStreamReader(System.in));
int[] list = new int[20];
for(int i =0; i< list.length; i++)
{
list[i] = Integer.parseInt(b.readLine());
}
return list;
}
public static int max(int[] array) {
// Find the maximum
int max = array[0];
for (int i = 1; i < array.length; i++)
{
if (array[i] > max)
max = array[i];
}
return max;
}