Forum Stats

  • 3,726,727 Users
  • 2,245,248 Discussions


Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Inner Classes

Vaishakh Menon
Vaishakh Menon Member Posts: 1

Hi All,

I have  a doubt regarding how .class files are named when we are  dealing with anonymous classes. I know that when we create a  inner class  one  .class file is generated named Outerclassname$InnerClass.class along with the normal .class file

and if we create an anonymous class then the .class file is named OuterClass$1.class

Now check this code :

Please assume I have a Test2 Class which has a method taste();

Now I am creating this code

public class Test{    public static void main(String[] args)


        Test2 a=new Test2(){          // Anonymous class is created so a .class file named Test$1 will be created

            //I am creating an another class inside anonymous class

            class MoreInner



            //Now again a new .class file named Test$1$MoreInner.class is created

            public void taste()









            System.out.println(10/0); // I am creating an exception so that I can enter catch block.

        } catch(ArithmeticException e){

            //Now I am again creating a class inside Catch block

            class checker


                public void eat()








Now my Question is from the above code  4 .class files should be created  as:

1) Test.class (for outer class)

2)Test$1.class(for anonymous class)

3)Test$1$MoreInner.class ( for class created inside anonymous class)

4)Test$checker.class (for class created inside catch block)

But name of 4th .class file is Test$1checker.class. Why there is a '1' before inner class name ? why it is Test$1checker.class instead of Test$checker.class ?


Sign In or Register to comment.