[Java]集合数组转化为 Stream 对象

  • Post author:
  • Post category:java



List    转为    Stream

List<String> list = new ArrayList<>();

Stream<String> stream = list.stream();


set    转为    Stream

Set<String> set = new HashSet<>();

Stream<String> stream1 = set.stream();


Map    转为    Stream

Map<String, Integer> map = new HashMap<>();

Set<Map.Entry<String, Integer>> entrySet = map.entrySet();

Stream<Map.Entry<String, Integer>> stream2 = entrySet.stream();


数组    转为    Stream

String[] arr = new String[3];

Stream<String> arr1 = Stream.of(arr);

Integer[] arr2 = new Integer[3];

Stream<Integer> arr21 = Stream.of(arr2);



版权声明:本文为P972742原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。