一 forEach /** * @Author ZiFan * @Date 2021/4/12 23:12 * @Description */ public class ForEachDemo { public static void main ( String [] args ) { List Province provinces = new ArrayList (); provinces . add ( new Province ( "1" , "贵州" ,
一 forEach
* @Author ZiFan
* @Date 2021/4/12 23:12
* @Description
*/
public class ForEachDemo {
public static void main(String[] args) {
List<Province> provinces=new ArrayList<>();
provinces.add(new Province("1","贵州","1005"));
provinces.add(new Province("2","黑龙江","1003"));
provinces.add(new Province("3","安徽","1002"));
provinces.add(new Province("4","内蒙古","1001"));
provinces.add(new Province("5","云南","1004"));
provinces.forEach(province -> {
province.setName(province.getName()+"_"+province.getLocalCode());
});
System.out.println(provinces);
}
}
//[Province(id=1, name=贵州_1005, localCode=1005), Province(id=2, name=黑龙江_1003, localCode=1003), Province(id=3, name=安徽_1002, localCode=1002), Province(id=4, name=内蒙古_1001, localCode=1001), Province(id=5, name=云南_1004, localCode=1004)]