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
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 ?
Welcome to the Ranch
I think you have misspelt the name of the fourth class. I think the reason you are getting such names would be obvious if you formatted your text properly; the indentation is so bad that nobody can read it. Please post the whole code again, with correct indentation.
Now you have corrected the indentation (thank you ), you can see that the named class is inside the anonymous class. You can see therefore that its .class file will be named Test$1checker.class, not Test$1Checker.class.