两种获取stream的方式
package com.mujiachao.stream;
import java.util.*;
import java.util.stream.Stream;
/**
* 转换成stream流的两种方法
*/
public class Demo3 {
public static void main(String[] args) {
/**
* 第一种
*/
ArrayList<Object> list = new ArrayList<>();
Stream<Object> stream = list.stream();
HashSet<Object> objects = new HashSet<>();
Stream<Object> stream1 = objects.stream();
HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
Set<Object> objects1 = objectObjectHashMap.keySet();
Stream<Object> stream2 = objects1.stream();
Collection<Object> values = objectObjectHashMap.values();
Stream<Object> stream3 = values.stream();
Set<Map.Entry<Object, Object>> entries = objectObjectHashMap.entrySet();
Stream<Map.Entry<Object, Object>> stream4 = entries.stream();
/**
* 第二种
*/
Stream<Integer> integerStream = Stream.of(1, 2, 5, 4, 6, 5, 4, 8, 7);
Integer[] arr={4,5,8,7,9,5,46,4};
Stream<Integer> arr1 = Stream.of(arr);
}
}