[英]How use streams for loop in jdk8?
How to use the for loop like this in jdk8.在jdk8中如何使用这样的for循环。
for (ClassAttendanceParent classAttendanceParent : list) {
TransportAttendanceFormBean tb = new TransportAttendanceFormBean();
tb.setDate(classAttendanceParent.getAttendancedate().toString());
}
in JDK8(How to convert the above for loop)在JDK8中(如何转换上面的for循环)
list.forEach((ClassAttendanceParent element) -> System.out.println(element.getAttendancedate()));
try this试试这个
list.forEach(element->{
TransportAttendanceFormBean tb = new TransportAttendanceFormBean();
tb.setDate(element.getAttendancedate().toString());
});
Or(no need to create new object in each iteration)或者(无需在每次迭代中创建新的 object)
TransportAttendanceFormBean tb = new TransportAttendanceFormBean();
list.forEach(element->{
tb.setDate(element.getAttendancedate().toString());
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.