Trying to convert a string, like "21 42 8 7 51" into an Integer array --> [21] [42] [8] etc...
list = "21 42 8";
String[] splitArray = list.split(" ");
int[] intArray = new int[splitArray.length];
for (int i = 0; i < splitArray.length; i++){
intArray[i] = Integer.parseInt(splitArray[i]);
}
for (int k = 0; k<intArray.length; k++){
System.out.println(intArray[k]);
}
The code is what I have written so far, and when I print what is supposed to be my Integer array, it only prints the first index