今天在开发中想实现题述的功能,初始代码如下:
List<Long> ids = attributeList.stream().map(a -> Long.getLong(a)).collect(Collectors.toList());
结果在运行的过程中发现ids的长度为1(attributeList的长度为1),但是里面的元素为空,导致始终得不到想要的结果,
后将代码改用Long.parseLong(),后结果正常:
List<Long> ids = attributeList.stream().map(a -> Long.parseLong(a)).collect(Collectors.toList());