Check class type

ReturnMethodSummary
booleanisAnnotation()is it an annotation type.
boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) Is an annotation present.
booleanisAnonymousClass()Is it an anonymous class.
booleanisArray()Is it an array class.
boolean isAssignableFrom(Class<?> cls) Is it assigned from.
booleanisEnum()Is it an enum.
booleanisInstance(Object obj)Is it instance of another object.
booleanisInterface()Is it an interface type.
booleanisLocalClass()Is it a local class.
booleanisMemberClass()Is it a member class.
booleanisPrimitive()Is it a primitive type.
booleanisSynthetic()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
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.