代码
提交代码
import java.util.List;
import java.util.Collections;
public class Test{
public static void main(String...s) {
List<Integer> numbers = new ArrayList<>();
Collections.addAll(numbers,new Integer[]{1,2,3,4,5,6,7});
Integer max = numbers.stream().max(Comparator.comparing(k->k)).get();
Integer min = numbers.stream().min(Comparator.comparing(k->k)).get();
System.out.println("max:"+max);
System.out.println("min:"+min);
}
}
运行结果