Aside from using the wrong method to compare strings, there is another serious problem: optionGet()
opens a new Scanner
on system.in
. If the input contains an option that is not A, B, or C, then optionGet()
calls itself recursively. The recursive call does another
Scanner ad = new Scanner(System.in);
while the first one is still open. There is no telling just what that will do, but it is likely to cause problems. Do not do that. Don't use recursion. It's inappropriate here. Instead, put the code that checks for options in a loop, and make sure new Scanner
is outside the loop.