From 12a794e1afe35feb5def375abdc58de8638d1397 Mon Sep 17 00:00:00 2001 From: Abdul Karim Date: Sun, 15 Feb 2026 13:06:06 +0500 Subject: [PATCH] 12.1. If: Added example of single statement if block --- src/branching_logic/if.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/branching_logic/if.md b/src/branching_logic/if.md index 3ec3a74..2604dde 100644 --- a/src/branching_logic/if.md +++ b/src/branching_logic/if.md @@ -38,3 +38,14 @@ if (age < 25) { If this condition evaluates to `false`, then the code inside of `{` and `}` will not run. + +NOTE: If you have only one statement, you do not need to put code inside of `{` and `}`. Moreover, the remaining lines will not be considered part of the if block. + +```java +~void main() { +int age = 20; +if (age < 25) + IO.println("You are too young to rent a car!"); // If condition evaluates to true +IO.println("Bye bye"); // Always printed +~} +```