What class files will be created during the compilation of the following code?
public class Count {
class A { }
public static void main(String[] args) {
Object obj = new Object() {
{ System.out.println(this); }
};
}
}
class Count$1 { }
Files for inner classes are named Outer$Inner, for anonimous classes - Outer$1, Outer$2, ... But $ is a legal symbol for identifiers and class Count$1 was already declared. Therefore, obj variable will contain a pointer to the anonimous class Count$2. So, 4 files will be created.
Login in to like
Login in to comment