written code but there is an error
import java.util.Scanner;
public class Main
{
public static void main (String[]args)
{
int[] array = { 2, 5, 7, 9, 8 };
System.out.println (maxarray (array));
}
public static int maxarray (int[]arr)
{
int max = Integer.MIN_VALUE;
for (int i = 0; i < arr.length; i++)
{
if (arr[i] > max)
{
max = arr[i];
}
return max;
}
}
}