Skip to content

Code Block

If we want the if statement to control more than one statement, we use a code block.

code block

Anything in curly braces { }.

if (condition) {
  statement to control
  other statement to control
}
Use a code block for your if statement even if it controls only one statement. * { } make the code more readable.

if (condition) {
  statement
}

Drill

IfElse/src/drills/SalaryDecisions.java * Run the program to see what it does. * Change the code according to the TODO's.


Prev -- Up -- Next