Conditions

Conditions run code depending on the result of a boolean test: if, else if, else, and the ternary operator ? :. The condition must be an expression of type boolean. Primitive types are compared with == and objects, including strings, with equals.

Example

if (note >= 10) {
    System.out.println("Passed");
} else {
    System.out.println("Failed");
}

Related concepts

The whole glossary