If you initialize a private variable and refer to it in a class and in an inner class, are you referring to the same instance? Something like this :
class MainClass
{
private int i;
private void method()
{
i = 10;
}
class InnerClass
{
i = 5;
}
}
Am I referring to the same i in both cases? One thing that surprises me is that this compiles successfully because I thought you could only access a private variable from the same class. It appears you can access them from inner classes too???
Also :
If my inner class is a
Thread will the change of i to 5 be 'seen' by the MainClass?