Java final variables

In Java, a final variable can be assigned only once. A final reference can still refer to a mutable object.

A simple example

Use a fixed value

  1. Start with Unit is 3
  2. Do this Multiply by 2
  3. Result 6
Give 3 a name and reuse that name in the multiplication.
Main.java
class Main {
    public static void main(String[] args) throws Exception {
        final int unit = 3;
        System.out.println(2 * unit);
    }
}
Output
6
Length of a slot: 30 minutes. Rehearsal: 3 slots. Time reserved: 90 minutes.
Reserve a rehearsal room

The music room can be booked in 30-minute slots. A rehearsal needs three slots, so the calendar sets aside 90 minutes. Naming the slot length lets every booking use the same rule.