I'm trying to collect input from the user, then if it's numeric – to turn it into an int, and if it's not – ask him to enter a numeric input
I'm using try/catch for this:
System.out.println("Col: ");
String temporary_col = sc.nextLine();
try {
int col = Integer.parseInt(temporary_col) - 1;
} catch (NumberFormatException e) {
System.out.println("Please enter a number");
int col = sc.nextInt() - 1;
}
and after that when I'm trying to use those variables:
field[col] = "X";
it returns this error:
java: cannot find symbol