IDEA out 文件夹中不显示内部类的 .class 文件
今天在学习 《Thinking in Java》时,想看看使用了内部类的 .java 文件编译后的 .class 文件中的内部类文件。
package chapter10.test10dot11;
interface Counter {
int next ();
}
public class LocalInnerClass {
private int count = 0;
Counter getCounter (final String name) {
class LocalCounter implements Counter {
public LocalCounter () {
System.out.println("LocalCounter()");
}
public int next () {
System.out.println(name);
return count++;
}
}
return new LocalCounter();
}
Counter getCounter2 (final String name) {
return new Counter () {
{
System.out.println("Counter");
}
public int next () {
System.out.println(name);
return count++;
}
};
}
public static void main(String[] args) {
LocalInnerClass lic = new LocalInnerClass();
Counter
c1 = lic.getCounter("Local inner "),
c2 = lic.getCounter2("Annoymous inner ");
for (int i = 0; i < 5; ++i) {
System.out.println(c1.next());
}
for (int i = 0; i < 5; ++i) {
System.out.println(c2.next());
}
}
}
当时却发现 IDEA 的 out 文件夹中竟然没有内部类的 .class 文件。
后来发现,实际上还是生成了内部类的 .class 文件,但是要使用 文件资源管理器打开文件夹才可以看到。
也不知道为什么 IDEA 要隐藏内部类的 .class 文件。