so I am creating a TicTacToe game right now and don't really know how to handle anything else but a int. Let's say the user input is a string - the program would throw a error. I actually want it to catch it and say something like "this is not a number between 1 and 9". How can I do this?
int nextPlayerTurn= scan.nextInt();
while (playerPosition.contains(nextPlayerTurn) ||computerPosition.contains(nextPlayerTurn)
|| nextPlayerTurn>= 10 || nextPlayerTurn<= 0 ) {
System.out.println("Position already taken! Please input a valid number (between 1 and 9) ");
nextPlayerTurn= scan.nextInt();