已有某集合对象:
List<CmsUserRole> userRoles = xxx集合对象
传统方式:
List<Integer> roleIds = new ArrayList<>(); for (CmsUserRole userRole : userRoles) { roleIds.add(userRole.getRoleId()); }
lambda 表达式方式:
List<Integer> roleIds = userRoles.stream().map(CmsUserRole::getRoleId).collect(Collectors.toList());
标签:List,userRoles,集合,roleIds,写法,表达式,lambda From: https://www.cnblogs.com/xuehuashanghe/p/16611400.html