Can fields of the class and arguments of the method interfere?
- by Roman
I have a class with a fields called "a". In the class I have a method and in the list of arguments of this method I also have "a". So, which "a" I will see inside of the method? Will it be the field or it will be the argument of the method?
public class myClass {
private String a;
// Method which sets the value of the field "a".
public void setA(String a) {
a = a;
}
}
By the way, there is a similar situation. A method has some local (for method) variables whose names coincide with the names of the fields. What will the "see" the method if I refer to such a method-local variable inside the method (the field or the local variable)?