You can have an if statement in a while statement, etc, and instead of doing else, you can do:
if(!bool) return "bool isn't true";
Instead of doing
if(bool){}else{return "bool isn't true";}
Replace bool with whatever value you want to compare.
You may replace bool with things like x>y
(if x is greater than y) or a boolean
value that you have defined.
solved about if and while statement in java programming? [closed]