Shadowing fields with a local variable or with a method parameter is a bad practice that reduces code readability: It makes it confusing to know whether the field or the variable is being used.
class Foo {
public int myField;
public void doSomething() {
int myField = 0;
...
}
public void doSomethingElse(int myField) {
...
}
}
Constructors and setters are exceptions; it is common practice to name arguments for the fields the values will be assigned to. Static methods are also ignored.
class Foo {
public int myField;
public Foo(int myField) {
this.myField = myField;
}
public static Foo build(int myField) {
...
}
public void setMyField(int myField){
this.myField = myField;
}
}