A non-static setter method can look like this:
private int var;
public void setVar(int var) {
this.var = var;
}
And I can't find out how to solve that with a static method:
private static int var;
public static void setVar(int var) {
// ???
}
One solution is to write myClass.var = var;. But that's ugly, because when I rename my class, I have to find and replace all occurrences.
Another solution is to rename the parameter to v and write var = v;. For me this is ugly, too.
Is there really no way to solve this like in php self::var = var;?
varis private, you never have to search somewhere else then in the class itself for references, when you rename you class without using a proper refactoring tool (like an IDE). Besides, how do you find all the imports in other types where you use the setter methodsetVar()if you do not use an IDE? I suggest you use an IDE and there should be no real problem out there.