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
3 Antworten
+ 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
+ 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")
}
0
else-if really are nested if-else statements