How do you get the reference to the class object of an anonymous inner class in Java?
With non-anonimous class it is done with ClassName.class.
How do you get the reference to the class object of an anonymous inner class in Java?
With non-anonimous class it is done with ClassName.class.
If for reference to the anonymous you ask a reference to the anonymous class, the
java.lang.Classinstance object to your anonymous class here is how you can do that.If you assign the anonimous class instance to the variable
objyou can have a reference to the class withobj.getClass(). The example usesObject, but any non-finalclass and any interface can be used.You can do the same also without explicitly creating a variable like obj for example
If no reference to the an object of type 'Anonymous' can be used (at least with reflection) you can't do that.