×

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

Empty Statement in Java

The three sorts of statements in Java are control, expression, and declaration statements. Additionally, another statement is referred to as an empty statement. In this section, we will discuss about...

4 minutes read.

Bad Operand types for Binary Operator Java

We will discuss how to handle issues in bad operand types for binary operator &, bad operand types for binary operator &&, bad operand types for binary operator ==, and...

4 minutes read.

Java Network Programming (Socket Programming in Java)

JAVA NETWORK Network programming is used to execute programs across multiple machines that are connected by a network. The java.net package contains a collection of classes and interfaces that provide this...

3 minutes read.

Java Math acos() Method

The acos() method of Math class computes the trigonometric Arc Cosine (inverse of cosine ) of an angle. The value returned is between 0.0 to pi. Syntax: public static double acos(double a) Parameters: The...

1 minute read.

Java Comparable Interface

We implement comparable interface when we need a new logic for determining equality. if two objects are equal, the equals() method returns true and compareTo() method returns 0. The basic...

1 minute read.

Nonagonal number in Java

Figureate numbers with the form n(7n-5)/2 are known as nonagonal numbers. 7n+3 will be a triangular number if n is a nonagonal number. The nonagon is included in the idea...

4 minutes read.

Zig Zag star and Number Pattern in Java

We covered many Java pattern applications in the preceding part. We will write Java applications for zigzag star and number patterns in this part. Printing Zig Zag Number Pattern Steps Print one...

3 minutes read.

Java Framework List

The framework is the programs which are written in Java. Frameworks in Java are used to create web applications. The code which can reuse can act as a reference for...

6 minutes read.

Java Case Keyword

Case keyword: In this article we are going to learn the concept of a java case keyword.Generally, java case keyword is used with the switch statements.Case keyword is implemented in conditional...

3 minutes read.

How to Concatenate Two Strings in Java

How to Concatenate Two Strings in Java Concatenation of two strings means adding the beginning of one string to the end of the other string. Some of the ways to concatenate...

3 minutes read.

Java Class Name

How to write a class name? The following considerations should be made while writing class names. The name of the current class shouldn't be based on a preset or existing class. Java keywords...

3 minutes read.

How to get ASCII value of char in Java

Introduction: On this application, you will learn how to find and show the ASCII value of char in Java. That is done with the use of type-casting and also everyday...

4 minutes read.

How to check valid date in Java?

Every time we get data for any application, we must first ensure that it is accurate before continuing with any further processing. We might have to confirm the following while dealing...

4 minutes read.

How to Convert Decimal to Octal in Java

How to Convert Decimal to Octal in Java There are two methods to convert Decimal to Octal: Using toOcatlString() method Using user-defined logic Using Integer.toOctalString() method The toOctalString() is astaticmethod of the Integer...

2 minutes read.

Highest precedence in Java

In Java, the operator is the first thing that springs to mind when discussing precedence. The order in which the operators in an expression are evaluated is controlled by a...

3 minutes read.

Java Transient

Java Transient In Java, Serialization is used to convert an object into a stream of the byte. The byte stream consists of the data of the instance as well as the...

3 minutes read.

Java Full Stack

A person who can create both the front end and back end of an application is a full-stack developer. In essence, the term "Java full-stack" refers to a web developer...

9 minutes read.

Automorphic Number Program in Java

We will learn about automorphic numbers through examples in this article, and we'll also make Java programmes that can determine whether a specific number was automorphic or not. What is an...

3 minutes read.

Longest Odd Even Subsequence in Java

In order to solve the Java problem known as the longest odd-even subsequence, one must identify a sequences in a non-negative array having size s that alternately includes odd and...

6 minutes read.

Java Abstraction

Java Abstraction Abstraction is an advanced feature of Java to make it transparent. The main motive behind the abstraction is to deal with ideas, not with events. Abstraction is a process...

4 minutes read.