Jdk 1.8 中forEach

Foreword

  • java 1.8 new in a forEach loop is very easy to use, when we write the interface background, the returned data sometimes need to add a field, then if modify the data table, then will be very complicated, resulting in unnecessary waste of time, Therefore, we can directly use the field to add the required cycle.

Renderings

Here Insert Picture Description
Here Insert Picture Description

Code

//用来保存处理完的对象
List<BankSysMenusPo> bSysMenusPo = new ArrayList<>();
从后台拿到的数据
List<Map<String, Object>>  banksysMenusDto =sysService.bankChildrenMenu(sysId);
			banksysMenusDto.forEach((data)->{
					data.put("module", data.get("kid"));
					data.put("id", data.get("kid"));
			}
Published 13 original articles · won praise 8 · views 1308

Guess you like

Origin blog.csdn.net/yaoliyuan0922/article/details/100577711