Order of execution in nested if-else loop
Why does the "else" statement works as if it is just another "if". Let me explain. What I expected from the following code is NOT to work. Since I removed {}, the last "else" statement shouldn't be triggered, because we already have "else" condition(to print: "Boy") P.S. A follow-up question- why use nested loops anyway? I know it looks better, but in the current case I could've just created three "if" statements and be good with it int x = 3; if (x >=10 ) //{ if (x >= 21 ) System.out.println("Man"); else System.out.println("Boy"); //} else System.out.println("Cub");