1.单列集合(直接调用)
ArrayList<Integer> list = new ArrayList<>();
list.stream();
2.双列集合
HashMap<String, Integer> map = new HashMap<>();
map.put("aaa",111);
map.put("bbb",222);
map.put("ccc",333);
map.put("ddd",444);
map.entrySet().stream();
3.数组
int []arr = new int[]{1,2,3,4,5,6,7};
Arrays.stream(arr).forEach(item-> System.out.println(item));
4.零散数据
形参可以是零散数据 也可以是数组 如果是数组里面存取的数据必须是引用类型,如果是基础类型会打印数组地址
Stream.of(1,2,3,4,5,6).forEach(item-> System.out.println(item));
Stream.of("a","b","c").forEach(item-> System.out.println(item));
int arr[] = new int[]{1,2,3,4,5};
String arr1[] = new String[]{"a","b","c"};
Stream.of(arr).forEach(item-> System.out.println(item));
Stream.of(arr1).forEach(item-> System.out.println(item));