Splitting a string separated by commas and storing the value into an int array
问题 I have a string which I want to split by the commas (easy process): String numbers = "1,2,3"; But, I then want to convert each element of the split string into an int that can be stored in an int array separated by commas as: int[][] array = new int [0][]; array[0] = new int[] {1,2,3}; How can I achieve this? 回答1: The 2D array is unnecessary. All you need to do is splice the commas out of the string using the split method. Then convert each element in the resulting array into an int. Here's