标签:reac 方法 pre 转换 string substr start pojo 测试
public static void main(String[] args) {
// 将 pojoList 转换至 dtoList 中
List<Student01> dtoList = new ArrayList<>();
List<Student01> pojoList = new ArrayList<>();
Collections.addAll(pojoList, new Student01(1, "靳露"), new Student01(2, "于瑶"), new Student01(4, "王莹"));
buildDtoList(pojoList).forEach(args1 -> dtoList.add(args1));
dtoList.forEach(args2 -> System.out.print(JSON.toJSON(args2) + " - ".substring(0,1)));
// TODO: {"name":"靳露","id":1} {"name":"于瑶","id":2} {"name":"王莹","id":4}
}
static List<Student01> buildDtoList(List<Student01> stuList) {
return stuList.stream().map(aItem -> {
Student01 student01 = new Student01();
student01.setId(aItem.getId());
student01.setName(aItem.getName());
return student01;
}).collect(Collectors.toList());
}
标签:reac 方法 pre 转换 string substr start pojo 测试
原文地址:https://www.cnblogs.com/Twittery/p/14844071.html