+ 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
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 .
+ 2
Here's an example of a nested if:
https://www.sololearn.com/discuss/193814/?ref=app