×

Java class class

Java Class class instances are an executing Java application's implementation of the classes and interfaces. As well as, every Array is indeed an object that is common for all Arrays that correspond to the Class. 

asSubclass(Class<U> clazz)It converts the supplied class object into this Class object to describe a subclass of that Class.
cast(Object obj)It converts an entity to the Class or interfaces that this Class object represents.
desiredAssertionStatus()Whenever the method is invoked, it returns the argument status, which would be given to this Class if it had been instantiated at that moment.
forName(String className)The Class object connected to the Class or method with the given string name is returned.
forName(String name, boolean initialize,ClassLoader loader)To use the chosen class loader, the method produces the Class object related to the Class or protocol with the provided string name.
getAnnotatedInterfaces()It gives back a list of Named Type objects, showing how the item that this Class object describes uses types to describe super interfaces.
getAnnotatedSuperclass()It gives back an Annotated Type object which illustrates how a type may be used to describe the default constructor of the object described through this Class object. Even if an annotation is available, this function returns it; otherwise, it provides null.
getAnnotation(Class annotationClass)It returns this entity's annotations for the specified type.
getAnnotations()   This function retrieves any annotations which are currently associated with this element.
getAnnotationsByType(ClassannotationClass)This function gives back any annotations connected to the element.
getCanonicalName()According to the Java Language Standard, it yields the conventional identity of the underneath class.
getClasses()It then produces an arrays comprising Class objects for each of the public protocols and classes that belong to the Class and therefore are referenced through this Class object.
getClassLoader()This function returns the Class's class loader.
getComponentType()This function returns the Class describing the component category of an array.
getConstructor(Class... parameterTypes)It gives back a Constructor object corresponding to the designated public function Object()  of both the Class that even this Class object represents.
getConstructors()It contains an array containing objects from the many public constructors of the Class that this Class object represents.
getDeclaredAnnotation(ClassannotationClass)Even when an annotation of the requested type is immediately present, it provides it; otherwise, it returns nil.
getDeclaredAnnotations()Annotations that are present on just this component are returned.
getDeclaredAnnotationsByType(Class annotationClass)If any such annotations were in any way available for the provided type, it provides the annotation(s) for this component.
getDeclaredClasses()It gives back an array of Class objects representing all the interfaces and classes listed as components of the Class that the object represents.
getDeclaredConstructor(Class... parameterTypes)The function Object()  of the Class or interfaces that Class object represents is reflected inside the Constructor object that this function would return.
getDeclaredConstructors()It returns a list of function Object()  objects that include each function Object() defined by the Class that this Class object represents.
getDeclaredField(String name)It gives back a Field object representing the stated field of the Class or protocol that now the Class object is meant to represent.
getDeclaredMethod(String name, Class... parameterTypes)It gives back a Method object which corresponds to the defined method of the Class or interfaces that even this Class object represents.
getDeclaringClass()It yields both the Class object indicating the Class for which it was defined and the Class or interfaces provided by this Class object, which really is a membership of some other class.
getEnclosingClass()It yields the upper Class's immediately surrounding Class.
getEnclosingConstructor()The returned Constructor object reflects the immediately preceding function Object()  of the fundamental Class if the requested Class's object indicates a local or anonymous class within a function Object().
getEnclosingMethod()A Method object that describes the leading up to the incident method of such fundamental Class is returned if the called Class object contains a local or anonymous Class within such a method.
getEnumConstants()If this Class object doesn't really match an enum type, zero is returned instead of the components of this enum class.
getField(String name)It gives back a Field object that corresponds to the provided public member field of the interfaces or Class that all this Class object is a representation of.
getFields()It produces an array of Field objects that represent each of the open, public properties of the interfaces or Class that this Class object represents.
getGenericInterfaces()    Returns the types that correspond to the interfaces that this object's corresponding Class or interface directly implements.
getGenericSuperclass()gets the Type corresponding to the entity (Class, interfaces, primitive type, or null) specified by this Class' indirect superclass.
getInterfaces()It identifies the interfaces that the interfaces or Class that this object represents implements.
getMethod(String name, Class... parameterTypes)It provides the requested public membership method of the interfaces or Class that this Class object represents in the form of a method object.
getMethods()It returns a list of Method objects that correspond to all of the public methods of the Class or interface that this Class object represents. The methods that are defined by the Class or interfaces as well as those that are derived from super classes or super interfaces are included as well.
getModifiers()It gives back the integer-encoded Java programming language modifiers specific to this Class or interface.
getName()It provides a String representation of the name of both the entity this Class object represents.
getPackage(It only obtains the Class's packages.
getProtectionDomain()    It gives back this Class's Protected Category.
getResource(String name)This approach looks for a source using the specified name.
getResourceAsStream(String name)   This approach looks for a component using a specific name.
getSigners()The current members of this Class are returned.
getSimpleName()  The name of the fundamental Class as specified in the source code is returned by this function.
getSuperclass()The Class referenced by the superclass of the thing this Class describes is returned by this method.
getTypeName()For the element's name, this function produces an informational string.
getTypeParameters()When t is called, it produces an array of Type Constant objects that, in publication order, reflect the type variables defined by the generic proclamation represented through this Generic Declaration objects.
isAnnotation()If this Class object matches an annotations type, this function will return a Boolean value of "true."
isAnnotationPresent(Class annotationClass)If an annotation is provided on this element, this function produces a Boolean value of "true,"; otherwise, it returns "false."
isAnonymousClass()If the underneath class is an anonymous class, then and only when it is, this function returns the Boolean value "true."
isArray()     This function ascertains whether this Class object would be an array class representative.
isAssignableFrom(Class cls)This function determines if the Class or interfaces indicated by the supplied Class argument is identical to, or a superclass or superinterface of, the Class or protocol indicated by that of the Class object.
isEnum()If the same Class was specified as an enum inside the source code, but if only it were, it outputs the Boolean value "true."
isInstance(Object obj) determines if the given Object is assignable to the object this Class represents.
isInterface()If the provided Class object contains a connection type, it is verified.
isLocalClass()If the fundamental Class is indeed a local class, this method yields the Boolean value "true."
isMemberClass()If the base class is a member class, this function will return a Boolean value of "true."
isPrimitive()This method determines if a specific primitive type is represented by the Class object given.
isSynthetic()In the event that the given Class is a synthetic class, this function returns the Boolean expression "true," otherwise, it returns "false."
newInstance()The Class that this Class object represents is created anew using this function.
toGenericString()This function provides a string containing data about the type parameters and modifiers and a description of this Class.
toString()The object is turned into a string using this technique.

Example: JavaClassExamples1.java

public class JavaClassExamples1 {  
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException {  
        // the Class will return the class name 
        Class clas1 = Class.forName("java.lang.String");  
        Class clas2 = int.class;  
        System.out.print("The class indicated by Clas1 is: ");  
        // method was used for the clas1
        System.out.println(clas1.toString());  
        System.out.print("Class represented by class2: ");  
        // the toString() method is used for the clas1 
        System.out.println(clas2.toString());  
        String str = "Programming";  
        int index = 145;  
  
        // verifying the objects of the Class
        boolean bool1 = clas1.isInstance(str);  
        boolean bool2 = clas1.isInstance(index);  
        System.out.println("Whether p instance of the String : " + bool1);  
        System.out.println("Whether j instance of the String : " + bool2);  
    }  
}  

Output

The Class indicated by Clas1 is: class java.lang.String
Class represented by class2: int
Whether p instance of the String : true
Whether j instance of the String : false

Related Topics

Zigzag Array in Java

In this tutorial, we discuss, what is zigzag array and its example. Even we will create the java program. In this program, we convert the simple array into a zigzag...

4 minutes read.

Minimum Number of Taps to Open to Water a Garden in Java

Problem Statement The issue is that a gardener wants to water a (single-dimensional) garden using the fewest possible tap openings. The goal is to determine the minimum necessary taps to be...

8 minutes read.

Java Math asin() Method

The asin() method of Math class computes the trigonometric Arc Sine (inverse of sine ) of an angle. The value returned is between -pi/2 to pi/2. Syntax: public static double asin(double a) Parameters: The...

1 minute read.

Java Constant

A constant is an unchangeable entity in coding, as its title implies. The value which cannot be altered, in other terms. We shall understand about Java constants and exactly how...

3 minutes read.

Java String intern() method

Java String intern() method returns canonical representation for the String Object. syntax: public String intern() Return: It returns a interned String that to be a pool of unique String. Java String intern() Example 1 public class...

2 minutes read.

3N+1 problem program in Java

The 3N+1 problem is a hypothesis in the field of abstract mathematics (not yet proven). Collectively known as the Collatz problem. This tutorial will describe about the 3N+1 problem and...

3 minutes read.

BigDecimal toString() in Java

BigDecimal is a Java class that is a part of the java.math package and the java.base module. It implements the ComparableBigDecimal> interface and extends the Number class. The BigDecimal class...

3 minutes read.

Why we use static in Java

Many reserved keywords in Java cannot be used as variable names or identifiers. Java uses static keywords frequently because of its effective memory management system. In most cases, you must...

3 minutes read.

Java TreeMap

TreeMap in Java with Example Java TreeMap implements the NavigableMap interface. It extends Map Interface. Java TreeMap is based on the red-black Tree implementation. It stores the key-value pair in sorted...

7 minutes read.

Java File

Java file class implements the concept of file handling. It has several methods, such as deleting, creating, reading, and updating files. This class allows java users to perform various operations...

5 minutes read.

Normal and Trace of a Matrix in Java

Normal of a matrix The square root of the total squares of each element in a matrix is known as the matrix's normal. Think of the following matrix as an example. Example: [[1,2,3]  ...

3 minutes read.

Virtual Function in Java

In the Operated Oriented Programming language, a virtual function or virtual method is a collection of functions that overrides the functionality of a function in an inheriting class with the same...

4 minutes read.

Java IO

It is a part of java libraries but is often known as I/O streams, file I/O, and file handling. The Java I/O concept satisfies the need for input processing and...

4 minutes read.

Java Binary Operators

In this article, we are going to discuss about the binary operators in Java and their operations. Also, an example program will be discussed along with the operations. These are...

6 minutes read.

Session Tracking in Java

When a series of requests from the same User (i.e., requests coming from the same browser) occurs over an extended period of time, servlets employ a mechanism known as session...

3 minutes read.

Palindrome Partitioning problem in Java

In this article, you will be acknowledged about partitioning of the palindrome. It can be done in many ways. This article makes sure every method is discussed. Palindrome If a string remains...

6 minutes read.

Java String format() method

format() method returns a formatted String based on the given locale,specified format and arguments. Syntax: public static String format(String format , Object… args) Parameter: locale : It specifies locale value to be applied on...

2 minutes read.

Vector in Java

Java Vector Class The Vector class is a legacy class that implements a growable array of objects. The components that it contains can be accessed using an integer index. The size of...

26 minutes read.

Java SHA256

Definition: In cryptography, SHA is a hash function that takes 20 bytes of input and produces an approximate 40-digit hexadecimal integer as the hash result. Class for Message Digest: Java's MessageDigest Class,...

2 minutes read.

Int vs Integer in Java

In Java, numerical data can be stored using int or Integer. int and Integer both have different definitions but similar usage in Java. What is int in Java? int is a primitive...

4 minutes read.