If¶
Java If Statement¶
The if statement in Java is a conditional control structure used to execute a block of code only if a specified condition is true.
If the condition evaluates to true, the code within the if block is executed; if false, the block is skipped.
Example¶
boolean condition1 = true;
if (condition1){
System.out.println("T"); // print T
}
boolean condition2 = false;
if (condition2){
System.out.println("T"); // T is not printed because condition2 is false
}
Short Video Lecture¶
(Video here)
VisualCodeChat Tutoring (Exercise: Check Positive)¶
Interact and Learn with VisualCodeChat!
After-class Exercises¶
(Exercises here)