So, I\'m getting stuck with this piece of code:
import java.util.InputMismatchException; import java.util.Scanner; public class ConsoleReader { Scanner
You may also try this:
public int readInt(String msg) { int num = 0; try { System.out.println(msg); num = (new Scanner(System.in)).nextInt(); } catch (InputMismatchException e) { System.out.println("Invalid value!"); num = readInt(msg); } return num; }