When I write setters for instance methods, I use this to disambiguate between the instance variable and the parameter:
public void setValue(int value) {
this.value = value;
}
So, what do I do when value is a class variable (static) instead of a member of an instance?
private static int value = 7;
public static void setValue(int value) {
value = value; // compile fails; ambiguous
}
Use <classname>.value = value;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With