Blocks
class Demo {
public static void main(String[] args) {
boolean condition = true;
if (condition) { // begin block 1
System.out.println("Condition is true.");
} // end block one
else { // begin block 2
System.out.println("Condition is false.");
} // end block 2
}
}
Is a group of zero or more statements between balanced braces and can be used anywhere a single statement is allowed.
Related concepts
→
Blocks
→
- The switch Statement
- Exception handler
- Local Variables
- Instance Variables
- Class/Static Variables
- The while Statement
- Statements, Expressions, and Blocks
- Class: Declaring Member Variables
- Class: Returning a Value from a Method
- The try Block
- The catch Blocks
- The finally Block
- ConcurrentHashMap
- Lambda Expressions