If a final variable references to an object, the reference must stay the same(not the object) : final « Modifiers « SCJP






class MyClass {
  int weight;

  MyClass(int w) {
    weight = w;
  }
}

public class MainClass {
  final MyClass w1 = new MyClass(1500);

  void test() {
    w1 = new MyClass(1400); // Illegal
    w1.weight = 1800; // Legal
  }
}








3.6.final
3.6.1.final variables
3.6.2.A final class cannot be subclassed.
3.6.3.If a final variable references to an object, the reference must stay the same(not the object)
3.6.4.A final method may not be overridden
3.6.5.final local variable indicates that the value of a variable cannot be changed once assigned a value.
3.6.6.Local variables and method parameters may also be declared as final to enable them to be accessed by local inner classes.
3.6.7.final method may not be overridden.
3.6.8.The final keyword means that the field cannot be changed once initialized.
3.6.9.A final variable can't have its value changed after initialization.
3.6.10.A local variable or method parameter must be declared final if it is to be used by an inner class declared inside a method.