可以使用以下代码实现:

String str = '1,2,3,4,5';
List<Integer> list = Arrays.stream(str.split(","))
        .map(Integer::valueOf)
        .collect(Collectors.toList());

首先,使用split函数将字符串按照逗号分割成字符串数组。然后使用Stream的map函数将每个字符串转换为整数类型,最后使用collect函数将结果收集到List中。

Java String类型字符串分割为整数List:使用Stream流

原文地址: https://www.cveoy.top/t/topic/ouEn 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录