0Pricing
Java Academy · Lesson

If Statements – Practice & Nested

Practice with nested if blocks, combine conditions safely, and compare strings correctly.

Lesson Goals

Goals: Practice if/else, write nested checks, and compare strings safely.

  • Nested if for multi-step decisions
  • Combine conditions with && and ||
  • Use equals for string comparison

Nested If

Nested if runs an inner check only when the outer condition is true.

public class Main {
    public static void main(String[] args) {
        int age = 16;

        if (age >= 0) {
            if (age < 18) {
                System.out.println("Minor");
            } else {
                System.out.println("Adult");
            }
        }
    }
}

All lessons in this course

  1. If Statements – Basics
  2. If Statements – Practice & Nested
  3. Common Pitfalls & Debugging Messages
← Back to Java Academy