将String[] 转成List<Integer>
将String[] 转成List<Integer>
public static void main(String[] args) throws Exception
{
String num= "1,2,3,4,5,6";
String[] statusArr = num.split(",");
int[] ints = Arrays.asList(statusArr).stream().mapToInt(Integer::parseInt).toArray();
List<Integer> collectNumber = Arrays.stream(ints).boxed().collect(Collectors.toList());
第二种方法
String[] statusArr = num.split(",");
List<Integer> statusNumber = Stream.of(statusArr).map(Integer::parseInt).collect(Collectors.toList());
}
浙公网安备 33010602011771号