what to do in case of
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 Exception {
int[] array = initializeArray();
int max = max(array);
System.out.println(max);
}
public static int[] initializeArray() throws IOException {
// Create and populate the arraya
int[] a=new int[20];
BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
for(int i=0;i<a.length;i++){
a[i]=Integer.parseInt(b.readLine());
}
return a;
}
public static int max(int[] array) {
int maxe=0;
for(int i=0;i<array.length;i++)
{
for(int j=1;j<array.length;j++){
if(array[0]<array[j])
maxe=array[j];
}
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 Exception {
int[] array = initializeArray();
int max = max(array);
System.out.println(max);
}
public static int[] initializeArray() throws IOException {
// Create and populate the arraya
int[] a=new int[20];
BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
for(int i=0;i<a.length;i++){
a[i]=Integer.parseInt(b.readLine());
}
return a;
}
public static int max(int[] array) {
// Find the maximum
// array=Integer.MAX_VALUE;
// int maxi=array[0];
// int max=array[1];
int maxe=0;
for(int i=0;i<array.length;i++)
{
for(int j=1;j<array.length;j++){
if(array[0]<array[j])
maxe=array[j];
}
}
return maxe;
}
}