{"title":"简化代码 List newoperations = new ArrayList<>();\n for (OperationBillItemsForDetailNoUpdateVo vo:operationBillItemsForDetailNoUpdateVos) {\n if (vo.getDetailNo()!=vo.getOldDetailNo()){\n newoperations.add(vo);\n }\n }\n if (newoperations.size()>0){\n operationBillItemsCoreDao.updatOperationBillItemsByOldDetailNo( operationBillItemsForDetailNoUpdateVos);\n }\n\n\n内容:简化后的代码如下:\n\nList newoperations = new ArrayList<>();\nfor (OperationBillItemsForDetailNoUpdateVo vo : operationBillItemsForDetailNoUpdateVos) {\n if (vo.getDetailNo() != vo.getOldDetailNo()) {\n newoperations.add(vo);\n }\n}\nif (!newoperations.isEmpty()) {\n operationBillItemsCoreDao.updatOperationBillItemsByOldDetailNo(operationBillItemsForDetailNoUpdateVos);\n}

Java代码优化:简化List操作并提高效率

原文地址: https://www.cveoy.top/t/topic/pImJ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录