Because your else isn’t attached to anything. The if without braces only encompasses the single statement that immediately follows it. if (choice==5) { System.out.println("End of Game\n Thank you for playing with us!"); break;...
  • April 4, 2022
  • 0 Comments
Use break: while (true) { .... if (obj == null) { break; } .... } However, if your code looks exactly like you have specified you can use a...
  • April 3, 2022
  • 0 Comments