See the following running code to print highest number in list by using java 8:-
package com.java8.array;
import java.util.Arrays;
import java.util.List;
import java.util.NoSuchElementException;
public class HeighestNumberInList {
public static void main(String[] args) {
List<Integer> integers = Arrays.asList(1, 2, 83, 4, 56, 7, 89, 10);
Integer max = integers.stream()
.mapToInt(v -> v)
.max().
orElseThrow(NoSuchElementException::new);
System.out.println("Max Interger value: "+max);
}
}
Output:-
Max Interger value: 89