使用Java8将对象里的某一个属性取出组成一个新的list
java
List<Spgg1> list=new ArrayList<>();
Spgg1 spgg1=new Spgg1();
spgg1.setSpdm("测试");
spgg1.setGgdm("001");
list.add(spgg1);
Spgg1 spgg2=new Spgg1();
spgg2.setSpdm("测试2");
spgg2.setGgdm("002");
list.add(spgg2);
List<String> strlist=list.stream().map(Spgg1::getSpdm).collect(Collectors.toList());
System.out.println(list);
System.out.println(strlist);