import java.util.*; import java.util.stream.Stream; public class demo_list_set_map_stream { public static void main(String[] args) { // list集合转Stream List<String> list=new ArrayList<>(); Stream<String> list_stream = list.stream(); // Set集合转Stream Set<String> set=new HashSet<>(); Stream<String> set_stream = set.stream(); // Map集合转Stream Map<String,String> map=new HashMap<>(); Stream<String> hm_set_stream = map.keySet().stream(); Stream<String> hm_val_stream = map.values().stream(); Stream<Map.Entry<String, String>> hm_en_stream = map.entrySet().stream(); // 数组转换为Stream Stream<Integer> integerStream = Stream.of(1, 2, 3, 4, 5, 6, 7); Stream<String> str_stream = Stream.of("abc", "abcd", "abcde"); } }