1 public static void main(String[] args) { 2 // Collection 集合获取 流 3 Collection<String> collection = new ArrayList<>(); 4 Stream<String> stream = collection.stream(); 5 6 // Map 集合获取 流 7 Map<String, Integer> map = new HashMap<>(); 8 // 获取 键 流 9 Stream<String> key = map.keySet().stream(); 10 // 获取 值 流 11 Stream<Integer> value = map.values().stream(); 12 // 获取 键值对 流 13 Stream<Map.Entry<String, Integer>> keyVal = map.entrySet().stream(); 14 15 // 数组获取 流 16 String[] names = {"张三", "李四", "王武"}; 17 Stream<String> list1 = Arrays.stream(names); 18 19 Stream<String> list2 = Stream.of(names); 20 }
标签:map,Stream,stream,Map,获取,names From: https://www.cnblogs.com/dsds/p/17987228