//1.Stream处理普通数据类型
public static void main(String[] args) {
Random random = new Random();
//1测试基本类型的数据;整数
List<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < 1000000; i++) {
list.add(random.nextInt(Integer.MAX_VALUE));
}
//一.简单数据类型的stream操作
//1.stream
testStream(list);
//2.parallelStream并行
testparallelStream(list);
//3.普通for
testfor(list);
//4.增强for
testStrongfor(list);
//5.迭代器
testIterator(list);
}
//流操作
public static void testStream(List<Integer> list) {
long start = System.currentTimeMillis();
//获取最大值
Optional<Integer> optional = list.stream().max(Integer::compare);
System.out.println(optional.get());
long end = System.currentTimeMillis();