Javatpoint Logo
Javatpoint Logo

Java Class Methods List

Java is a popular programming language with an object-oriented, class-based paradigm. A Java class is a blueprint or template specifying program objects' properties and operations. The operations in those one or more methods may define the Java class's objects. We will go into great detail about the many kinds of Java class methods in this post.

Modifier & Type Description
<U>Class<?extendsU> Casts this Class object to represent a subclass of the class represented by the specified class object.
T Casts an object to the class or interface represented by this Class object.
boolean returns the assertion status that would be given to this class if it were initialised at the time this method is called.
static Class<?> forName(String className) returns the Class object related to the specified string name's class or interface.
static Class<?> forName(String name, boolean initialize, ClassLoader loader) Using the specified class loader, returns the Class object related to the class or interface with the provided string name.
AnnotatedType[] Returns an array of AnnotatedType objects that show how the entity that this Class object represents uses types to express its superinterfaces.
Annotation[] Annotations that are present on this element are returned by getAnnotations().
<A extends Annotation>A[] Annotations that are connected to this element are returned by A[]
String The String function returns the Java Language Specification's definition of the canonical name of the underlying class.
Class<?>[] getClasses() returns an array of Class objects that represent each public class and interface that belong to the class that this Class object represents.
ClassLoader The class loader for the class is returned by classloader.
Class<?> returns the Class corresponding to the type of an array's component.
Constructor<T> Returns a Constructor object that reflects the specified public constructor of the class represented by this Class object.
Constructor<?>[] Returns an array containing Constructor objects reflecting all the public constructors of the class represented by this Class object.
<A extends Annotation> GetDeclaredAnnotation returns the annotation for the given type for this element if it is directly present; else, it returns null.
Annotation[] Annotations that are directly present on this element are returned by the function getDeclaredAnnotations().
<A extends Annotation> A[] A[]getDeclaredAnnotationsByType(ClassA> annotationClass) returns the annotation(s) for this element that are either directly or indirectly present for the provided type.
Class<?>[] Get all the classes and interfaces that have been declared as members of the class that this Class object represents by returning an array of Class objects using the getDeclaredClasses() function.
Constructor<T> Returns a Constructor object that reflects the supplied constructor of the class or interface that this Class object represents. Constructor<T> returns a Constructor object.
Constructor<?>[] getDeclaredConstructors() Provides a Constructor object array containing all the constructors that the class represented by this Class object has specified.
Field Returns a Field object that corresponds to the defined field of the class or interface that this Class object represents.
Field[] returns an array of Field objects containing all the fields that were defined in the class or interface that this Class object is a representation of.
Method A Method object that reflects the declared method of the class or interface that this Class object represents is returned by the call to getDeclaredMethod(String name, Class?>... parameterTypes).
Method[] A method object array comprising all the declared methods of the class or interface that this Class object represents, including public, protected, default (package) access, and private methods, but omitting inherited methods, is returned by the getDeclaredMethods() function.
int The Java language modifiers for this class or interface are returned using the int getModifiers() method.
String The function String getName() returns the name of the object (class, interface, array class, primitive type, or void) that this Class object represents.
Package the class's package may be found using the package getPackage().
ProtectionDomain The ProtectionDomain of this class is returned by the ProtectionDomain getProtectionDomain() method.
URL findResource(String name) locates the resource specified by the provided name.
InputStream The getResourceAsStream() method of an input stream locates a resource with the specified name.
Object[] getSigners() retrieves the class' signers.
String getSimpleName() returns the class's basic name as specified in the source code.
String getTypeName() Return a descriptive string for the type's name.
TypeVariable<Class<T>>[] The function getTypeParameters() returns a list of TypeVariable objects that, in declaration order, reflect the type variables declared by the generic declaration represented by this GenericDeclaration object.
boolean isInterface()
ascertains whether the supplied Class object is an interface type.
boolean isLocalClass()
Only if the underlying class is a local class will this function return true.
boolean isMemberClass()
If and only if the underlying class is a member class, then it returns true.
boolean isPrimitive()
checks to see whether the given Class object represents a primitive type.






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA