Im working with the following code to determine the max Array value its only printing the first Array value at the first index could you please help me and tell me why its not getting me the max value from the Array Thanks | Selenium Forum
A
Ashik Das Posted on 18/04/2019

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);




}

}


A
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