Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What name do you use for the parameter in a static variable setter method?

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
}
like image 243
skiphoppy Avatar asked Feb 04 '09 18:02

skiphoppy


1 Answers

Use <classname>.value = value;

like image 79
Michael Myers Avatar answered Nov 02 '22 22:11

Michael Myers