Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

We can see that the value of a and b has been changed, which means that when you declare a reference final, it only means that the reference can not be changed but the contents it refer to can still be changed! 

...


NonCompliant Solution

If you do not want to change a and b after they are initialized, the simplest approach is to declare a and b final: private final int a;
 private final int b; 

Code Block

 private final int a;
 private final int b;

But now you can not have setter method of a and b.

...