Close

Java Reflection - Class.isAnonymousClass() Examples

Code Snippets Java Reflection Java 


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 isAnonymousClass()
Returns:
true if and only if this class is an anonymous class.


Examples


package com.logicbig.example.clazz;

public class IsAnonymousClassExample {

public static void main(String... args) {
Class<? extends Object> c = new Object() {}.getClass();
boolean b = c.isAnonymousClass();
System.out.println(b);
}
}

Output

true




See Also