Close

Java Reflection - Class.isInterface() Examples

Code Snippets Java Reflection Java Java API 


Class:

java.lang.Class

java.lang.Objectjava.lang.Objectjava.lang.Classjava.lang.Classjava.io.SerializableSerializablejava.lang.reflect.GenericDeclarationGenericDeclarationjava.lang.reflect.TypeTypejava.lang.reflect.AnnotatedElementAnnotatedElementLogicBig

Method:

public boolean isInterface()
Returns:
true if this object represents an interface; false otherwise.

Examples


package com.logicbig.example.clazz;

public class IsInterfaceExample {

public static void main(String... args) {
boolean b = Runnable.class.isInterface();
System.out.println(b);
}
}

Output

true




package com.logicbig.example.clazz;

public class IsInterfaceExample2 {

public static void main(String... args) {
Class<Override> c = Override.class;
System.out.println(c.isInterface());
System.out.println(c.isAnnotation());
}
}

Output

true
true




See Also