As per Joshua Bloch's book "Effective Java", Item 15 - Minimize mutability, using final
keyword on private class fields in addition to immutability and thread-safe syncing could improve performance.
class Immutable {
private final int readOnly;
public Immutable(int readOnly) {
this.readOnly = readOnly;
}
public int getReadOnly() {
return readOnly;
}
}
But sometimes, especially in Android code i see something like this:
class MyClass {
private void myMethod() {
final List<A> list = new ...;
final B b = new B();
...
}
}
When final
word applied to reference object. This means that the reference isn't mutable, but has it any influence on performance?