Java NullPointerException: element cannot be mapped to a null key问题解决
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
免费下载资源
·
问题描述:
java.lang.NullPointerException: element cannot be mapped to a null key
问题分析:
1、使用Collectors.groupingBy()进行分组时,分组值存在null值。
List<String> strList = new ArrayList<>(Arrays.asList("11", "12", "13", null, null));
Map<String, List<String>> map = strList.stream().collect(Collectors.groupingBy(x -> x));
解决办法:分组值为null时,默认值为空字符。
List<String> strList = new ArrayList<>(Arrays.asList("11", "12", "13", null, null));
Map<String, List<String>> map = strList.stream().collect(Collectors.groupingBy(x -> StrUtil.isEmpty(x) ? "" : x));
GitHub 加速计划 / eleme / element
10
1
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:4 个月前 )
c345bb45
8 个月前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 8 个月前
更多推荐
已为社区贡献20条内容
所有评论(0)