views:

85

answers:

1

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
}
+7  A: 

Use <classname>.value = value;

Michael Myers
Gah; I feel stupid...
skiphoppy
It's always obvious in retrospect. :)
Michael Myers