See this program
public class Test{
public static void main(
String[]args){
Test.A ob = new
Test().new A();
System.out.println(ob.i);//Possible--line 1
Super ob1 = new Super();
//System.out.println(ob1.j);Compile time error.--line 2
}
class A{
private int i = 0;
}
}
class Super{
private int j = 23;
}
One object can access a private variable of another object of the same calss. So Line 1 produce no compile time error. But Line 2 produce error.
This is the same case for your program.If your class B not in this class A then this produce compile error.