You can combine multiple conditions in a single if using logical operators. && means AND (both sides must be true). || means OR (at least one side must be true).
int age = 25;
boolean hasTicket = true;
if (age >= 18 && hasTicket) {
System.out.println("You may enter");
}
This prints only when both conditions are true. If either is false, the block is skipped.
if (age < 13 || age > 65) {
System.out.println("Discounted ticket");
}
This prints when at least one condition is true. A -year-old gets the discount. A -year-old also gets it.
Java uses short-circuit evaluation. With &&, if the left side is false, Java skips the right side entirely. With ||, if the left side is true, Java skips the right side. This matters when the right side has side effects or could throw an error.