Hey guys, is this a bug? I think it does a good Job.
Thanks for looking at it
package com.codegym.task.task07.task0701;
import java.io.IOException;
import java.util.Arrays;
/*
1. The initializeArray method must create an array of 20 integers.
2. The initializeArray method must read in 20 numbers and return them as an array.
3. The max method must return the maximum element in the passed array.
4. Don't change the main method.
*/
public class Solution {
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 {
int[] array = new int[20];
for(int i = 0; i<array.length; i++)
{
array[i] = 1 + i;
}
return array;
}
public static int max(int[] array) {
Arrays.sort(array);
return array[array.length-1];
}
}