package nilpointer.net;
import java.util.ArrayList;
import java.util.List;
public class Demo {
public static void main(String[] args) {
List<Integer> numbers = new ArrayList<Integer>();
numbers.add(5);
numbers.add(2);
numbers.add(11);
numbers.add(-9);
numbers.add(7);
numbers.add(-4);
long max1 = numbers.stream().min((number1, number2) -> number2 - number1).get();
System.out.println("max 1: " + max1);
long max2 = numbers.stream().filter(p -> p < 7).min((number1, number2) -> number2 - number1).get();
System.out.println("max 2: " + max2);
}
}
max 1: 11
max 2: 5