Lesson 1 of 512 minModule progress 0%

Module 4: Decision Making

Booleans and Conditions

Use boolean values and readable conditions as the foundation for every branching statement in Java.

Author

Java Learner Editorial Team

Reviewer

Technical review by Java Learner

Last reviewed

2026-04-16

Java version

Java 25 LTS

How this lesson was prepared: AI-assisted draft, edited by hand, and checked against current Java 25 documentation and runnable examples.

Learning goals

  • Understand what a boolean represents
  • Write a simple condition that evaluates to true or false
  • Read boolean output confidently before using `if` statements

Why this matters: Decisions in Java start with boolean results. Before writing if, you should feel comfortable reading conditions that produce true or false.

A boolean variable: A boolean holds only two values: true or false.

A condition is an expression: When Java evaluates something like score >= 50, the result is a boolean value.

Keep conditions readable: A good condition should sound clear in English, such as "score is at least 50" or "user is logged in."

Runnable examples

Store booleans directly

public class Main {
    public static void main(String[] args) {
        boolean isLoggedIn = true;
        boolean isMember = false;
        System.out.println(isLoggedIn);
        System.out.println(isMember);
    }
}

Expected output

true
false

A condition becomes a boolean

public class Main {
    public static void main(String[] args) {
        int score = 72;
        boolean passed = score >= 50;
        System.out.println(passed);
    }
}

Expected output

true

Common mistakes

Treating conditions as something different from booleans

A condition is just an expression whose result is `true` or `false`.

Mini exercise

Create a number variable and a boolean named `isPositive` that checks whether the number is greater than 0.

Summary

  • Booleans store true/false.
  • Conditions evaluate to booleans.

Next step

Now put those conditions inside an `if` statement.

Sources used

Advertisement

Lesson check

What type of value does `age >= 18` produce?

Next lesson →