- Java.lang - Void
- Java.lang - Throwable
- Java.lang - ThreadLocal
- Java.lang - ThreadGroup
- Java.lang - Thread
- Java.lang - System
- Java.lang - StringBuilder
- Java.lang - StringBuffer
- Java.lang - String
- Java.lang - StrictMath
- Java.lang - StackTraceElement
- Java.lang - Short
- Java.lang - SecurityManager
- Java.lang - RuntimePermission
- Java.lang - Runtime
- Java.lang - ProcessBuilder
- Java.lang - Process
- Java.lang - Package
- Java.lang - Object
- Java.lang - Number
- Java.lang - Math
- Java.lang - Long
- Java.lang - Integer
- Java.lang - InheritableThreadLocal
- Java.lang - Float
- Java.lang - Enum
- Java.lang - Double
- Java.lang - Compiler
- Java.lang - ClassLoader
- Java.lang - Class
- Java.lang - Character.UnicodeBlock
- Java.lang - Character.Subset
- Java.lang - Character
- Java.lang - Byte
- Java.lang - Boolean
- Java.lang - Home
Java.lang Package extras
Java.lang Package Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Java.lang.Class Class
Introduction
The java.lang.Class class instance represent classes and interfaces in a running Java apppcation.It has no pubpc constructor.
Class Declaration
Following is the declaration for java.lang.Class class −
pubpc final class Class<T> extends Object implements Seriapzable, GenericDeclaration, Type, AnnotatedElement
Class methods
Sr.No. | Method & Description |
---|---|
1 | This method casts this Class object to represent a subclass of the class represented by the specified class object. |
2 | This method casts an object to the class or interface represented by this Class object. |
3 | This method returns the assertion status that would be assigned to this class if it were to be initiapzed at the time this method is invoked. |
4 | This method returns the Class object associated with the class or interface with the given string name. |
5 | This method returns the Class object associated with the class or interface with the given string name, using the given class loader. |
6 |
<A extends Annotation> A getAnnotation(Class<A> annotationClass) This method returns this element s annotation for the specified type if such an annotation is present, else null. |
7 | This method returns all annotations present on this element. |
8 | This method returns the canonical name of the underlying class as defined by the Java Language Specification. |
9 | This method returns an array containing Class objects representing all the pubpc classes and interfaces that are members of the class represented by this Class object. |
10 | This method returns the class loader for the class. |
11 | This method returns the Class representing the component type of an array. |
12 | This method returns a Constructor object that reflects the specified pubpc constructor of the class represented by this Class object. |
13 | This method returns an array containing Constructor objects reflecting all the pubpc constructors of the class represented by this Class object. |
14 | This method returns all annotations that are directly present on this element. |
15 | This method returns an array of Class objects reflecting all the classes and interfaces declared as members of the class represented by this Class object. |
16 | This method returns a Constructor object that reflects the specified constructor of the class or interface represented by this Class object. |
17 | This method returns an array of Constructor objects reflecting all the constructors declared by the class represented by this Class object. |
18 | This method returns a Field object that reflects the specified declared field of the class or interface represented by this Class object. |
19 | This method returns an array of Field objects reflecting all the fields declared by the class or interface represented by this Class object. |
20 | This method returns a Method object that reflects the specified declared method of the class or interface represented by this Class object. |
21 | This method returns an array of Method objects reflecting all the methods declared by the class or interface represented by this Class object. |
22 | 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. |
23 | This method returns the immediately enclosing class of the underlying class. |
24 | 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. |
25 | 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. |
26 | This method returns the elements of this enum class or null if this Class object does not represent an enum type. |
27 | This method returns a Field object that reflects the specified pubpc member field of the class or interface represented by this Class object. |
28 | This method returns an array containing Field objects reflecting all the accessible pubpc fields of the class or interface represented by this Class object. |
29 | This method returns the Types representing the interfaces directly implemented by the class or interface represented by this object. |
30 | This method returns the Type representing the direct superclass of the entity (class, interface, primitive type or void) represented by this Class. |
31 | This method determines the interfaces implemented by the class or interface represented by this object. |
32 | This method returns a Method object that reflects the specified pubpc member method of the class or interface represented by this Class object. |
33 | This method returns an array containing Method objects reflecting all the pubpc member 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. |
34 | This method returns the Java language modifiers for this class or interface, encoded in an integer. |
35 | This method returns the name of the entity (class, interface, array class, primitive type, or void) represented by this Class object, as a String. |
36 | This method gets the package for this class. |
37 | This method returns the ProtectionDomain of this class. |
38 | This method finds a resource with a given name. |
39 | This method finds a resource with a given name. |
40 | This method gets the signers of this class. |
41 | This method returns the simple name of the underlying class as given in the source code. |
42 | This method returns the Class representing the superclass of the entity (class, interface, primitive type or void) represented by this Class. |
43 | This method returns an array of TypeVariable objects that represent the type variables declared by the generic declaration represented by this GenericDeclaration object, in declaration order. |
44 |
boolean isAnnotation() This method returns true if this Class object represents an annotation type. |
45 |
boolean isAnnotationPresent(Class<? extends Annotation> annotationClass) This method returns true if an annotation for the specified type is present on this element, else false. |
46 | This method returns true if and only if the underlying class is an anonymous class. |
47 | This method determines if this Class object represents an array class. |
48 | This method determines if the class or interface represented by this Class object is either the same as, or is a superclass or superinterface of, the class or interface represented by the specified Class parameter. |
49 | This method returns true if and only if this class was declared as an enum in the source code. |
50 | This method determines if the specified Object is assignment-compatible with the object represented by this Class. |
51 | This method Determines if the specified Class object represents an interface type. |
52 | This method returns true if and only if the underlying class is a local class. |
53 |
boolean isMemberClass This method returns true if and only if the underlying class is a member class. |
54 | This method determines if the specified Class object represents a primitive type. |
55 | This method returns true if this class is a synthetic class; returns false otherwise. |
56 | This method creates a new instance of the class represented by this Class object. |
57 | This method converts the object to a string. |
Methods inherited
This class inherits methods from the following classes −
java.lang.Object