Mai Temp
0
Q:

java how to find the largest number in an arraylist

List<Integer> myList = new ArrayList<>();

for(int i = 0; i < 10; i++){
    myList.add(i);
}
//gets highest number in the list
int highestNumber = Collections.max(myList);

System.out.Println(highestNumber);

//output: 9
5
int max = (The provided List).stream().max((i1,i2)->(i1>i2)?1:(i1<i2)-1:0).get();
0

New to Communities?

Join the community