When it comes to java, Suppose I is an interface, What is meant by I.class? And what is it use for?
3 Answers
Every class or interface you write is associated with a java.lang.Class object during runtime in Java. All instances of the same class share the same Class object and you can obtain the Class object by calling the CLassName/InterfaceName.class or obj.getClass() method of the corresponding object. Read the What is the use of class “java.lang.Class” ? article for more details.
Comments
It's the Class instance for the interface, I. With it, you can find the methods and fields of the interface, check to see if objects implement the interface, etc.
Type.class is syntactic sugar for obtaining object Class object via Class.forName(). Although the "class" might seem out of place when applied to an interface, it works the same way, and provides much of the same information. You won't be able to reflect on any constructors, however.
<ClassName>.classis the way you obtain a reference to that object. (And an interface is just a special type of class.)