Since I could not find an easy way to convert my string array to an integer array, I was looking for an example for a method, and here is what I got:
private int[] convert(String string) {
int number[] = new int[string.length()];
for (int i = 0; i < string.length(); i++) {
number[i] = Integer.parseInt(string[i]);
}
return number;
}
parseInt requires a string, which is the string [i], but the error tells me: "The type of the expression must be an array type, but it is allowed for String"
I can’t understand what the problem is with my code.
EDIT: I'm an idiot. Thank you, everything was obvious.
source
share