0

question regarding "Nested if Statements"

I just wanted to know that what is the use of nested "if statements". Please help by giving an example of a code

10th Jun 2017, 3:40 PM
sushant
sushant - avatar
3 odpowiedzi
+ 2
A nested if-statement is an if statement with another if-statement in it: if(a==b){ if(b==c){ System.out.println("a is b is c") } else if(b==d){ System.out.println("a is b is d") } } So if b==d is true, but a==b isn't, the whole loop won't run
10th Jun 2017, 5:58 PM
Maart
Maart - avatar
+ 1
if(age < 13){ System.out.println("You're a Kid!!!"); System.out.println("Good bye"); } else{ System.out.printl("Welcome!"); if(age < 18) System.out.printl("Teenager"); else System.out.printl("Adult") }
10th Jun 2017, 3:52 PM
Andrés04_ve
Andrés04_ve - avatar
0
else-if really are nested if-else statements
10th Jun 2017, 3:53 PM
Andrés04_ve
Andrés04_ve - avatar