I was reading about Inner class in Learning Java. I found this code
class Animal{
class Brain{
}
}
After compiling, javap 'Animal$Brain'
gives output as
Compiled from "Animal.java"class
Animal$Brain {
final Animal this$0;
Animal$Brain(Animal);
}
which explains how the inner class gets the reference to its enclosing instance in the inner class constructor. But when I define the inner class as private like this
class Animal{
private class Brain{
}
}
then after compiling, javap 'Animal$Brain'
gives the output as
Compiled from "Animal.java"
class Animal$Brain {
final Animal this$0;
}
So why is the output different? Why is the inner class constructor not shown? In the latter case also, the inner class is getting the reference of enclosing class instance.