Nested if Statement :-
- The nested if statement is if statement inside the if statement.
- Example:-
int a = 25;
if (a > 0){
if(a > 16){
System.out.println("Welcome");
}else{
System.out.println("Too young");
}
}else{
System.out.println("Error");
}
If..else if statement:-
- Instead of using nested if statement , we can use the else if statement to check multiple condition.
- Example:-
int a = 25;
if (a > 0){
System.out.println("Error");
}else if(a <= 16){
System.out.println("Too young");
}else if(a < 100){
System.out.println("Welcome !");
}else{
System.out.println("Really ?");
}