.collect(Collectors.toList())报java.lang.NullPointerException错误

java.lang.NullPointerException为空指针错误,原因出在Collectors.toList()时候里面有null值导致的。

知道大概的方向后,我就想应该是被查询的List里面包含了null值,所以对程序进行Debug,发现被查询的List在Debug视图里面出现了“Not showing null elements”

 看来是印证了我的才行,因此对被查询的List进行过滤。

过滤null值后的List就没再出现“Not showing null elements”

程序也变为正常

Guess you like

Origin blog.csdn.net/qq_17486399/article/details/118900536