Ed Heal :
Consider the following code:
public class myclasss {
private static int somevar;
public setSomeVar(int somevar) {
somevar = somevar;
}
}
Obviously the code somevar = somevar;
does not make sense. Is it possible to set the variable somevar
to somevar
without changing the parameters name? (i.e. differentiate between the two variables)?
Andy Turner :
Yes, qualify the name of the static variable:
myclasss.somevar = somevar;
Similarly for an instance variable:
private int anothervar;
public setAnothervar(int anothervar) {
this.anothervar = anothervar;
}
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=415610&siteId=1