I am trying to read user input from a scanner into an integer array, I currently have this:
int [] arr1 = {Integer.parseInt(sc.nextLine().split(" "))};
But i am given the error
String[] cannot be converted to String
Any help would be much appreciated :)
Integer.parseIntconverts single strings to integers. But you attempt to use it on aString[](result ofsplit), so multiple strings. You have to execute the method individually on all elements of theString[]and then collect theints back to an array.