Check class type
boolean isAnnotation()
- is it an annotation type.
boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
- Is an annotation present.
boolean isAnonymousClass()
- Is it an anonymous class.
boolean isArray()
- Is it an array class.
boolean isAssignableFrom(Class<?> cls)
- Is it assigned from.
boolean isEnum()
- Is it an enum.
boolean isInstance(Object obj)
- Is it instance of another object.
boolean isInterface()
- Is it an interface type.
boolean isLocalClass()
- Is it a local class.
boolean isMemberClass()
- Is it a member class.
boolean isPrimitive()
- Is it a primitive type.
boolean isSynthetic()
- Is it a synthetic class.
public class Main {
public static void main(String[] args) {
Class c = new String().getClass();
System.out.println(c.isInterface());
}
}
The output:
false