private void nextCell(char[][] cells, Scanner sc) {
int coX = 0;
int coY = 0;
while (true) {
System.out.println("Enter the coordinates: ");
try {
coX = Integer.parseInt(sc.next());
coY = Integer.parseInt(sc.next());
} catch (Exception e) {
System.out.println("You should enter numbers!");
}
break;
}
原文:https://www.cnblogs.com/longlong6296/p/13917599.html