How can I get the complier to read a nested if statement inside an else if statement? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can I get the complier to read a nested if statement inside an else if statement?

int a; int num = 50; System.outprintln("please choose the option 1, 2 or 3"); Scanner option = new Scanner (); a = option.nextInt(); if(a==1) { } else if(a==2) { system.out.println("enter a number") Scanner option = new Scanner (); d = option.nextInt(); if(d>Num) { System.out.println("Error"); } } else(c==3) { } //the complier does not pick up the code with the nested if statement

1st May 2017, 1:04 AM
Theophilus Mashego
Theophilus Mashego - avatar
2 Answers
+ 5
make a=2 if the else if statement isn't returned true, it won't look inside to find the nested statement .
1st May 2017, 1:08 AM
LordHill
LordHill - avatar
+ 2
Here's an example of a nested if: https://www.sololearn.com/discuss/193814/?ref=app
1st May 2017, 1:24 AM
Igor B
Igor B - avatar