Eclipse has a java compiler setting called "field declaration hides another field or variable" that can be set to warning/error.
How important is this warning in your opinion?
What is a good standard way to handle this problem?
Code example of where this happens:
public class Test {
private String caption = null;
public Test(String caption) { // here
this.caption = caption;
}
}
I've seen solutions where the field is renamed, i.e "fCaption", but that would cause the automatic getters/setters that can be genereated to have odd names (getfCaption()
).
Not unreadable, but ugly...
Edit: Oh yea, there is the possibility to rename the method signature Test(String caption_)
or something similar, but that would end up in the javadoc looking weird.