If I have code like this:
public class Foo {
public int bar;
public void setBar(int bar) {
bar = bar;
}
}
Eclipse warns me that the assignment doesn't do anything (for obvious reasons). Can I fix it by changing it to this.bar = bar; or is it best to just use a different variable name?
this.foo = foo;is an accepted convention in a set method or constructor.