Java record -89-java.lang.class

Source: Internet
Author: User

It is well known that Java has an object class, which is the root cause of all Java classes, which declares several methods:hashcode (), Equals (), Clone (), which should be rewritten in all Java classes. ToString (), GetClass (), and so on. where GetClass () returns a class object.

The class class is very special and inherits from object as the general classes, whose entities are used to express the classes and interfaces of the Java program runtime and to express the enum, array, primitive Java Types (Boolean, Byte, char, short, int, long, float, double) and keyword void.

When a class is loaded, or when the defineclass () of the Loader (class loader) is called by the JVM, the JVM automatically generates a Class object.

Java JDK Source code can see the construction method of the class is private, and annotated as: Constructor, only the Java Virtual machine creates class objects. Java only A virtual machine can create a class object. The class class contains many native methods, local methods, not implemented in Java, but implemented by C or C + +.

Class is the origin of reflection, and for any class you want to explore, you only have to create a class object for it, and then you can evoke more than 10 reflection APIs through the latter.

Java allows us to generate the corresponding class object for a class from multiple sources:

1. Use GetClass (); (Each class has this function)

2. Use of Class.getsuperclass ();

3. Using the static method Class.forName (); (most commonly used)

4. Using the. class syntax (class str = string.class)

5. Using the TYPE syntax of primitive wrapper classes (Class C1 = integer.type)


Java record -89-java.lang.class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.