I am confused about the concept of interface when dealing with anonymous inner class. As far as I know that you can\'t instantiate an interface in Java, so the following sta
You're defining an inner class with a sequentially assigned name like 1
, 2
, 3
etc. At the same time you're instantiating the inner class with the new
keyword. You don't care about the name of the inner class because you're using it anonymously. If you look in your bin directory you'll see a class file for each of the anonymous definitions. For example if you used an anonymous class in a class, Foo
, you would have Foo.class
and Foo$1.class
created for you. I believe this means that you could instantiate more of the anonymous classes at a later date using reflection.