Splitting String and put it on int array

后端 未结 8 1408
眼角桃花
眼角桃花 2020-11-28 14:03

I have to input a string with numbers ex: 1,2,3,4,5. That\'s a sample of the input, then I have to put that in an array of INT so I can sort it but is not working the way it

8条回答
  •  半阙折子戏
    2020-11-28 15:00

    List stringList = new ArrayList(Arrays.asList(arr.split(",")));
    List intList = new ArrayList();
    for (String s : stringList) 
       intList.add(Integer.valueOf(s));
    

提交回复
热议问题