Run shows no error, but output is always 0
package com.codegym.task.task07.task0701;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
Maximum in an array
*/
public class Solution {
public static void main(String[] args) throws IOException {
int[] array = initializeArray();
int maxi = max(array);
System.out.println(maxi);
}
public static int[] initializeArray() throws IOException {
// Create and populate the array
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int[] arr = new int[20];
for(int i=0;i<arr.length;i++){
int s = Integer.parseInt(br.readLine());
}
return arr;
}
public static int max(int[] array) {
// Find the maximum
int maximum = array[0];
for(int i=0;i<array.length;i++){
if(maximum<array[i])
maximum = array[i];
}
return maximum;
}
}