Class (Java Platform SE 8 ) (original) (raw)
Modifier and Type
Method
Description
<U> [Class](../../java/lang/Class.html "class in java.lang")<? extends U>
[asSubclass](../../java/lang/Class.html#asSubclass-java.lang.Class-)([Class](../../java/lang/Class.html "class in java.lang")<U> clazz)
Casts this Class
object to represent a subclass of the class represented by the specified class object.
[T](../../java/lang/Class.html "type parameter in Class")
[cast](../../java/lang/Class.html#cast-java.lang.Object-)([Object](../../java/lang/Object.html "class in java.lang") obj)
Casts an object to the class or interface represented by this Class
object.
boolean
[desiredAssertionStatus](../../java/lang/Class.html#desiredAssertionStatus--)()
Returns the assertion status that would be assigned to this class if it were to be initialized at the time this method is invoked.
static [Class](../../java/lang/Class.html "class in java.lang")<?>
[forName](../../java/lang/Class.html#forName-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") className)
Returns the Class
object associated with the class or interface with the given string name.
static [Class](../../java/lang/Class.html "class in java.lang")<?>
[forName](../../java/lang/Class.html#forName-java.lang.String-boolean-java.lang.ClassLoader-)([String](../../java/lang/String.html "class in java.lang") name, boolean initialize,[ClassLoader](../../java/lang/ClassLoader.html "class in java.lang") loader)
Returns the Class
object associated with the class or interface with the given string name, using the given class loader.
[AnnotatedType](../../java/lang/reflect/AnnotatedType.html "interface in java.lang.reflect")[]
[getAnnotatedInterfaces](../../java/lang/Class.html#getAnnotatedInterfaces--)()
Returns an array of AnnotatedType
objects that represent the use of types to specify superinterfaces of the entity represented by thisClass
object.
[AnnotatedType](../../java/lang/reflect/AnnotatedType.html "interface in java.lang.reflect")
[getAnnotatedSuperclass](../../java/lang/Class.html#getAnnotatedSuperclass--)()
Returns an AnnotatedType
object that represents the use of a type to specify the superclass of the entity represented by this Class
object.
<A extends [Annotation](../../java/lang/annotation/Annotation.html "interface in java.lang.annotation")> A
[getAnnotation](../../java/lang/Class.html#getAnnotation-java.lang.Class-)([Class](../../java/lang/Class.html "class in java.lang")<A> annotationClass)
Returns this element's annotation for the specified type if such an annotation is present, else null.
[Annotation](../../java/lang/annotation/Annotation.html "interface in java.lang.annotation")[]
[getAnnotations](../../java/lang/Class.html#getAnnotations--)()
Returns annotations that are present on this element.
<A extends [Annotation](../../java/lang/annotation/Annotation.html "interface in java.lang.annotation")> A[]
[getAnnotationsByType](../../java/lang/Class.html#getAnnotationsByType-java.lang.Class-)([Class](../../java/lang/Class.html "class in java.lang")<A> annotationClass)
Returns annotations that are associated with this element.
[String](../../java/lang/String.html "class in java.lang")
[getCanonicalName](../../java/lang/Class.html#getCanonicalName--)()
Returns the canonical name of the underlying class as defined by the Java Language Specification.
[Class](../../java/lang/Class.html "class in java.lang")<?>[]
[getClasses](../../java/lang/Class.html#getClasses--)()
Returns an array containing Class
objects representing all the public classes and interfaces that are members of the class represented by this Class
object.
[ClassLoader](../../java/lang/ClassLoader.html "class in java.lang")
[getClassLoader](../../java/lang/Class.html#getClassLoader--)()
Returns the class loader for the class.
[Class](../../java/lang/Class.html "class in java.lang")<?>
[getComponentType](../../java/lang/Class.html#getComponentType--)()
Returns the Class
representing the component type of an array.
[Constructor](../../java/lang/reflect/Constructor.html "class in java.lang.reflect")<[T](../../java/lang/Class.html "type parameter in Class")>
[getConstructor](../../java/lang/Class.html#getConstructor-java.lang.Class...-)([Class](../../java/lang/Class.html "class in java.lang")<?>... parameterTypes)
Returns a Constructor
object that reflects the specified public constructor of the class represented by this Class
object.
[Constructor](../../java/lang/reflect/Constructor.html "class in java.lang.reflect")<?>[]
[getConstructors](../../java/lang/Class.html#getConstructors--)()
Returns an array containing Constructor
objects reflecting all the public constructors of the class represented by thisClass
object.
<A extends [Annotation](../../java/lang/annotation/Annotation.html "interface in java.lang.annotation")> A
[getDeclaredAnnotation](../../java/lang/Class.html#getDeclaredAnnotation-java.lang.Class-)([Class](../../java/lang/Class.html "class in java.lang")<A> annotationClass)
Returns this element's annotation for the specified type if such an annotation is directly present, else null.
[Annotation](../../java/lang/annotation/Annotation.html "interface in java.lang.annotation")[]
[getDeclaredAnnotations](../../java/lang/Class.html#getDeclaredAnnotations--)()
Returns annotations that are directly present on this element.
<A extends [Annotation](../../java/lang/annotation/Annotation.html "interface in java.lang.annotation")> A[]
[getDeclaredAnnotationsByType](../../java/lang/Class.html#getDeclaredAnnotationsByType-java.lang.Class-)([Class](../../java/lang/Class.html "class in java.lang")<A> annotationClass)
Returns this element's annotation(s) for the specified type if such annotations are either directly present or_indirectly present_.
[Class](../../java/lang/Class.html "class in java.lang")<?>[]
[getDeclaredClasses](../../java/lang/Class.html#getDeclaredClasses--)()
Returns an array of Class
objects reflecting all the classes and interfaces declared as members of the class represented by this Class
object.
[Constructor](../../java/lang/reflect/Constructor.html "class in java.lang.reflect")<[T](../../java/lang/Class.html "type parameter in Class")>
[getDeclaredConstructor](../../java/lang/Class.html#getDeclaredConstructor-java.lang.Class...-)([Class](../../java/lang/Class.html "class in java.lang")<?>... parameterTypes)
Returns a Constructor
object that reflects the specified constructor of the class or interface represented by thisClass
object.
[Constructor](../../java/lang/reflect/Constructor.html "class in java.lang.reflect")<?>[]
[getDeclaredConstructors](../../java/lang/Class.html#getDeclaredConstructors--)()
Returns an array of Constructor
objects reflecting all the constructors declared by the class represented by thisClass
object.
[Field](../../java/lang/reflect/Field.html "class in java.lang.reflect")
[getDeclaredField](../../java/lang/Class.html#getDeclaredField-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") name)
Returns a Field
object that reflects the specified declared field of the class or interface represented by this Class
object.
[Field](../../java/lang/reflect/Field.html "class in java.lang.reflect")[]
[getDeclaredFields](../../java/lang/Class.html#getDeclaredFields--)()
Returns an array of Field
objects reflecting all the fields declared by the class or interface represented by thisClass
object.
[Method](../../java/lang/reflect/Method.html "class in java.lang.reflect")
[getDeclaredMethod](../../java/lang/Class.html#getDeclaredMethod-java.lang.String-java.lang.Class...-)([String](../../java/lang/String.html "class in java.lang") name,[Class](../../java/lang/Class.html "class in java.lang")<?>... parameterTypes)
Returns a Method
object that reflects the specified declared method of the class or interface represented by thisClass
object.
[Method](../../java/lang/reflect/Method.html "class in java.lang.reflect")[]
[getDeclaredMethods](../../java/lang/Class.html#getDeclaredMethods--)()
Returns an array containing Method
objects reflecting all the declared methods of the class or interface represented by this Class
object, including public, protected, default (package) access, and private methods, but excluding inherited methods.
[Class](../../java/lang/Class.html "class in java.lang")<?>
[getDeclaringClass](../../java/lang/Class.html#getDeclaringClass--)()
If the class or interface represented by this Class
object is a member of another class, returns the Class
object representing the class in which it was declared.
[Class](../../java/lang/Class.html "class in java.lang")<?>
[getEnclosingClass](../../java/lang/Class.html#getEnclosingClass--)()
Returns the immediately enclosing class of the underlying class.
[Constructor](../../java/lang/reflect/Constructor.html "class in java.lang.reflect")<?>
[getEnclosingConstructor](../../java/lang/Class.html#getEnclosingConstructor--)()
If this Class
object represents a local or anonymous class within a constructor, returns a Constructor object representing the immediately enclosing constructor of the underlying class.
[Method](../../java/lang/reflect/Method.html "class in java.lang.reflect")
[getEnclosingMethod](../../java/lang/Class.html#getEnclosingMethod--)()
If this Class
object represents a local or anonymous class within a method, returns a Method object representing the immediately enclosing method of the underlying class.
[T](../../java/lang/Class.html "type parameter in Class")[]
[getEnumConstants](../../java/lang/Class.html#getEnumConstants--)()
Returns the elements of this enum class or null if this Class object does not represent an enum type.
[Field](../../java/lang/reflect/Field.html "class in java.lang.reflect")
[getField](../../java/lang/Class.html#getField-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") name)
Returns a Field
object that reflects the specified public member field of the class or interface represented by this Class
object.
[Field](../../java/lang/reflect/Field.html "class in java.lang.reflect")[]
[getFields](../../java/lang/Class.html#getFields--)()
Returns an array containing Field
objects reflecting all the accessible public fields of the class or interface represented by this Class
object.
[Type](../../java/lang/reflect/Type.html "interface in java.lang.reflect")[]
[getGenericInterfaces](../../java/lang/Class.html#getGenericInterfaces--)()
Returns the Type
s representing the interfaces directly implemented by the class or interface represented by this object.
[Type](../../java/lang/reflect/Type.html "interface in java.lang.reflect")
[getGenericSuperclass](../../java/lang/Class.html#getGenericSuperclass--)()
Returns the Type
representing the direct superclass of the entity (class, interface, primitive type or void) represented by this Class
.
[Class](../../java/lang/Class.html "class in java.lang")<?>[]
[getInterfaces](../../java/lang/Class.html#getInterfaces--)()
Determines the interfaces implemented by the class or interface represented by this object.
[Method](../../java/lang/reflect/Method.html "class in java.lang.reflect")
[getMethod](../../java/lang/Class.html#getMethod-java.lang.String-java.lang.Class...-)([String](../../java/lang/String.html "class in java.lang") name,[Class](../../java/lang/Class.html "class in java.lang")<?>... parameterTypes)
Returns a Method
object that reflects the specified public member method of the class or interface represented by thisClass
object.
[Method](../../java/lang/reflect/Method.html "class in java.lang.reflect")[]
[getMethods](../../java/lang/Class.html#getMethods--)()
Returns an array containing Method
objects reflecting all the public methods of the class or interface represented by this Class
object, including those declared by the class or interface and those inherited from superclasses and superinterfaces.
int
[getModifiers](../../java/lang/Class.html#getModifiers--)()
Returns the Java language modifiers for this class or interface, encoded in an integer.
[String](../../java/lang/String.html "class in java.lang")
[getName](../../java/lang/Class.html#getName--)()
Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this Class
object, as a String
.
[Package](../../java/lang/Package.html "class in java.lang")
[getPackage](../../java/lang/Class.html#getPackage--)()
Gets the package for this class.
[ProtectionDomain](../../java/security/ProtectionDomain.html "class in java.security")
[getProtectionDomain](../../java/lang/Class.html#getProtectionDomain--)()
Returns the ProtectionDomain
of this class.
[URL](../../java/net/URL.html "class in java.net")
[getResource](../../java/lang/Class.html#getResource-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") name)
Finds a resource with a given name.
[InputStream](../../java/io/InputStream.html "class in java.io")
[getResourceAsStream](../../java/lang/Class.html#getResourceAsStream-java.lang.String-)([String](../../java/lang/String.html "class in java.lang") name)
Finds a resource with a given name.
[Object](../../java/lang/Object.html "class in java.lang")[]
[getSigners](../../java/lang/Class.html#getSigners--)()
Gets the signers of this class.
[String](../../java/lang/String.html "class in java.lang")
[getSimpleName](../../java/lang/Class.html#getSimpleName--)()
Returns the simple name of the underlying class as given in the source code.
[Class](../../java/lang/Class.html "class in java.lang")<? super [T](../../java/lang/Class.html "type parameter in Class")>
[getSuperclass](../../java/lang/Class.html#getSuperclass--)()
Returns the Class
representing the superclass of the entity (class, interface, primitive type or void) represented by thisClass
.
[String](../../java/lang/String.html "class in java.lang")
[getTypeName](../../java/lang/Class.html#getTypeName--)()
Return an informative string for the name of this type.
[TypeVariable](../../java/lang/reflect/TypeVariable.html "interface in java.lang.reflect")<[Class](../../java/lang/Class.html "class in java.lang")<[T](../../java/lang/Class.html "type parameter in Class")>>[]
[getTypeParameters](../../java/lang/Class.html#getTypeParameters--)()
Returns an array of TypeVariable
objects that represent the type variables declared by the generic declaration represented by thisGenericDeclaration
object, in declaration order.
boolean
[isAnnotation](../../java/lang/Class.html#isAnnotation--)()
Returns true if this Class
object represents an annotation type.
boolean
[isAnnotationPresent](../../java/lang/Class.html#isAnnotationPresent-java.lang.Class-)([Class](../../java/lang/Class.html "class in java.lang")<? extends [Annotation](../../java/lang/annotation/Annotation.html "interface in java.lang.annotation")> annotationClass)
Returns true if an annotation for the specified type is present on this element, else false.
boolean
[isAnonymousClass](../../java/lang/Class.html#isAnonymousClass--)()
Returns true
if and only if the underlying class is an anonymous class.
boolean
[isArray](../../java/lang/Class.html#isArray--)()
Determines if this Class
object represents an array class.
boolean
[isAssignableFrom](../../java/lang/Class.html#isAssignableFrom-java.lang.Class-)([Class](../../java/lang/Class.html "class in java.lang")<?> cls)
Determines if the class or interface represented by thisClass
object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specifiedClass
parameter.
boolean
[isEnum](../../java/lang/Class.html#isEnum--)()
Returns true if and only if this class was declared as an enum in the source code.
boolean
[isInstance](../../java/lang/Class.html#isInstance-java.lang.Object-)([Object](../../java/lang/Object.html "class in java.lang") obj)
Determines if the specified Object
is assignment-compatible with the object represented by this Class
.
boolean
[isInterface](../../java/lang/Class.html#isInterface--)()
Determines if the specified Class
object represents an interface type.
boolean
[isLocalClass](../../java/lang/Class.html#isLocalClass--)()
Returns true
if and only if the underlying class is a local class.
boolean
[isMemberClass](../../java/lang/Class.html#isMemberClass--)()
Returns true
if and only if the underlying class is a member class.
boolean
[isPrimitive](../../java/lang/Class.html#isPrimitive--)()
Determines if the specified Class
object represents a primitive type.
boolean
[isSynthetic](../../java/lang/Class.html#isSynthetic--)()
Returns true
if this class is a synthetic class; returns false
otherwise.
[T](../../java/lang/Class.html "type parameter in Class")
[newInstance](../../java/lang/Class.html#newInstance--)()
Creates a new instance of the class represented by this Class
object.
[String](../../java/lang/String.html "class in java.lang")
[toGenericString](../../java/lang/Class.html#toGenericString--)()
Returns a string describing this Class
, including information about modifiers and type parameters.
[String](../../java/lang/String.html "class in java.lang")
[toString](../../java/lang/Class.html#toString--)()
Converts the object to a string.