Listlist = new ArrayList<>(); Person p1 = new Person("张三", 20, "江西"); Person p2 = new Person("李四", 22, "北京"); Person p3 = new Person("赵六", 26, "广东"); list.add(p1); list.add(p2); list.add(p3); String str = list.stream().map(Person::getName).collect(Collectors.joining(",")); System.out.println(str);//张三,李四,赵六 //转list集合 List list2 = list.stream().map(Person::getName).collect(Collectors.toList()); list2.forEach(s -> System.out.println(s.toString())); //2、条件遍历 list2.forEach(c->{ if(c.equals("张三")){ System.out.println(c); } }); //set集合 Set set = list.stream().map(Person::getName).collect(Collectors.toCollection(TreeSet::new));



