Stream流将String的数字集合转成Integer类型数字集合

int[] ints = recordDTO.getIdList().stream().mapToInt(Integer::parseInt).toArray();
		List<Integer> ids = Arrays.stream(ints).boxed().collect(Collectors.toList());

测试
《Stream流将String的数字集合转成Integer类型数字集合》
《Stream流将String的数字集合转成Integer类型数字集合》

注意,必须是数字的字符串,不然会报错

《Stream流将String的数字集合转成Integer类型数字集合》
《Stream流将String的数字集合转成Integer类型数字集合》

    原文作者:菜鸟ZhAng~
    原文地址: https://blog.csdn.net/weixin_56227932/article/details/123984273
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞