List
list.add(new Person(“1001”, “小A”));
list.add(new Person(“1002”, “小B”));
list.add(new Person(“1003”, “小C”));
System.out.println(list);
//将list转换map
Map<String, String> map = list.stream().collect(Collectors.toMap(Person::getId, Person::getName));
- List
result = staff.stream().map(temp -> { - StaffPublic obj = new StaffPublic();
- obj.setName(temp.getName());
- obj.setAge(temp.getAge());
- if (“mkyong”.equals(temp.getName())) {
- obj.setExtra(“this field is for mkyong only!”);
- }
- return obj;
- }).collect(Collectors.toList());