站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2SE 专题编译后的class文件名里有$字符,是咋回事啊?

编译后的class文件名里有$字符,是咋回事啊?

摘要: 编译后的class文件名里有$字符,是咋回事啊?


使用javac命令编译得到class文件,大部分*.class的文件名都和*.java文件名是一致的,但是发现其中有一些class文件的名字比较奇怪,文件名中间带了$字符,如下:

KScript$ExportAction.class
KScript$LibFilter.class
KScript$NewAction.class
...

请问,这表示什么意思呢?




在类的内部的一些内部类和匿名类,编译后就会有这样的类名了。


Inner classes are translated into regular class files with $ (dollar signs) delimiting outer and inner class names, and the virtual machine does not have any special knowledge about them.

For example, the TimePrinter class inside the TalkingClock class is translated to a class file TalkingClock$TimePrinter.class.


签名标识内隐类


类内的内部类和匿名类...


你的类里面 包含了匿名类或者内部类就会出现这种结果


↑返回目录
前一篇: JAVA虚拟机怎么用?急!在线等!
后一篇: 多态性