Inner Class in Java

北城余情 提交于 2019-12-04 02:36:53
code

Good question. According to this,

If no options are used, javap prints out the package, protected, and public fields and methods of the classes passed to it

Since you have declared Brain as a private inner class, its default constructor will be implicitly made private and hence it will not be visible outside the Animal class.

Ref: http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.8.9

By default, javap prints non private members of the classes.

You can use -p option to shows all classes and members.

//javap -p 'Animal$Brain.class'

Compiled from "Animal.java"
class Animal$Brain {
  final Animal this$0;
  private Animal$Brain(Animal);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!