i’ve this code
public class MasterClass {
private String myVariable;
private ValuesClass objectA;
class ValuesClass {
public void method() {
myVariable = 1; // I can't access myVariable
}
}
}
How to access myVariable from inside ValuesClass ?
What you are doing is exactly correct. Except that
myVariableis aString, and you are trying to assign anintto it.Now, if your inner class ALSO had a variable called
myVariable, you would need some special syntax to access the one from the outer class:Edit by Martijn: This is called a Qualified This.