Converting String Array to an Integer Array

后端 未结 6 1183
我寻月下人不归
我寻月下人不归 2020-11-29 05:24

so basically user enters a sequence from an scanner input. 12, 3, 4, etc.
It can be of any length long and it has to be integers.
I want to convert the

6条回答
  •  执念已碎
    2020-11-29 05:49

    Java has a method for this, "convertStringArrayToIntArray".

    String numbers = sc.nextLine();
    int[] intArray = convertStringArrayToIntArray(numbers.split(", "));
    

提交回复
热议问题