Nested if Statements
Nested if Statements
if statements inside other if statements are called nested if statements.
Example:
Output:
if statements inside other if statements are called nested if statements.
Example:
public class Nested {
public static void main(String[] args) {
String name = "Coco";
int Roll = 25;
int marks = 85;
if (name == "Coco" && Roll == 25) {
if (marks > 35) {
System.out.println("Coco has been promoted to next class.");
} else {
System.out.println("Coco needs to give re-exam.");
}
}
}
}
Output:
Coco has been promoted to next class.
Sorry, we detected that you have activated Ad-Blocker.
Please consider supporting us by disabling your Ad-Blocker, it helps us in developing this Website.
Thank you!