Versions Compared

Key

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

...

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

Code Block
 void set_ab(int a, int b){ //But now compiler complains about set_ab method!
  this.a = a;
  this.b = b;
 }
 private final int a;
 private final int b;

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

Compliant Solution

...