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
Java 8 offers a streams-based alternative to manual iteration:
int[] intArray = Arrays.stream(input.split(","))
.mapToInt(Integer::parseInt)
.toArray();
Be prepared to catch NumberFormatException
if it's possible for the input to contain character sequences that cannot be converted to an integer.
List<String> stringList = new ArrayList<String>(Arrays.asList(arr.split(",")));
List<Integer> intList = new ArrayList<Integer>();
for (String s : stringList)
intList.add(Integer.valueOf(s));