java find highest value in list code example
Example 1: how to get the highest value in a list java
import java.util.*;
public class CollectionsMaxExample2 {
public static void main(String[] args) {
//Create collections lists.
List list = Arrays.asList(20, 10, 100, 140, 250);
Integer max = Collections.max(list);
System.out.println("Maximum element is: "+max);
}
Example 2: java find largest number in list
int max = (The provided List).stream().max((i1,i2)->(i1>i2)?1:(i1