public class FindGreatestNumber {
public static void main( String[] args){
// finding greatest number in a Array
int[] x ={1,7774,989,738,8902};
int max = x[0];
for(int i=1; i<x.length; i++){
if (x[i]> max)
{
x[i]= max;
}
}
System.out.println("max value from Array :" + max);
}
}
Instructor
Ashish Thakur Replied on 20/04/2019
You need to sort the array in asending order
Once you do that you can pick index 0 and that will be max