一、Stream
1、概述
2、Stream流使用过程
示例图:
3、 Stream流的常见生成方式
示例:
package itbianma01; import java.util.*; import java.util.stream.Stream; public class Demo { public static void main(String[] args) { //方式一:Collection体系的集合可以使用默认方法stream生成流 List<String> list = new ArrayList<>(); Stream<String> listStream = list.stream(); Set<String> set = new HashSet<>(); Stream<String> setStream = set.stream(); //方式二:map体系的集合间接地生成流 Map<String, Integer> map = new HashMap<>(); Stream<String> keyStream = map.keySet().stream(); Stream<Integer> valueStream = map.values().stream(); Stream<Map.Entry<String, Integer>> entryStream = map.entrySet().stream(); //方式三:数组 String[] array = {"java", "hello", "world"}; Stream<String> strArrayStream = Stream.of(array); Stream<String> strArrayStream1 = Stream.of("java", "hello", "world"); Stream<Integer> intStream = Stream.of(10, 20, 30); } }
4、Stream流常见中间操作
标签:map,java,Stream,stream,示例,new From: https://www.cnblogs.com/qtiger/p/17919729.html