0

Trouble with my if-else nested statements

I keep getting a Java error 17 saying that my else statement does not have an if statement to go with it and I am not sure how to fix it since I have an if statement and I should be able to add as many else statements as I want to it. https://code.sololearn.com/c1OUpSoJkE7F/?ref=app

17th Jul 2020, 6:13 PM
Angel Armndariz
Angel Armndariz - avatar
2 Answers
+ 1
Angel Armndariz , second else statement is on the wrong place. You can see it in the code. https://code.sololearn.com/co1eHfjCQ68y/?ref=app
17th Jul 2020, 6:18 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 1
//Problem in closing braces for if: public class NestedIfStatements { public static void main(String[] args) { int age = 25; if(age > 0) { if(age > 16) { System.out.println("Welcome!"); } else { System.out.println("You're a baby still"); } }//close outer if here.. else { System.out.println("Error, enter another number"); } } } Edit: you can add any number "else if" as you needed..
17th Jul 2020, 6:18 PM
Jayakrishna🇮🇳
Jayakrishna🇮🇳 - avatar