break statement in “if else” – java
Because your else isn’t attached to anything. The if without braces only encompasses the single statement that immediately follows it. Not using braces is generally viewed as a bad practice because it can lead to the exact problems you encountered. In addition, using a switch here would make more sense. Note that instead of an infinite for loop I used a while(boolean), making it … Read more