¿Cómo puedo lograr esto?¿La variable miembro y la variable de método local tienen el mismo nombre?
class Test {
private int var1;
public Test(int var1) {
var1 = var1; //set the member variable to what was passed in
}
}
Estoy seguro de que hay una respuesta muy obvia. Solo me estoy escapando ahora mismo.
Eche un vistazo a un buen código. Verás que exactamente esto ('this.x = x') se usa para setters y constructores. No tiene sentido inventar un nuevo nombre. – maaartinus