Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scanner sc = new Scanner(System.in);
- static String getMenuInput(String scannerPattern) {
- String input = null;
- while (input == null) {
- input = sc.findInLine(scannerPattern);
- sc.nextLine();
- }
- return input;
- }
- String menuInput;
- menuInput = getMenuInput("B|R|Q"); // This works, returns value that can be used to navigate menu
- menuInput = getMenuInput("0-9"); // This gets stuck in the loop (apparently not able to find pattern)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement