Java.lang.Class class

Source: Internet
Author: User

The first contact class is in learning jdbc. Class.forName () is a static method of the class class that is used to manually load a class, such as a database driver.

In fact, every Java class has or says a class instance object, and some tutorials explain that "everything is Object" when the class is the object of class (then class itself). The class object corresponding to each Java class is the generated class file with the same name. The primary function of class is to obtain information about a class, such as member variables/methods/constructs, and so on, and he saves the structure of the class.

When a class is used: It takes several steps to use its static method or instantiate its object: Load, connect, initialize. When the JVM loads a class, it loads its bytecode file and generates the corresponding class object. During the connection process, first verify the integrity of the class file, prepare the memory area for the static field of the class, and then parse the object. Finally initializes the class, such as executing a static statement block, initializing the static member variable.

It is important to note that there is no continuity between loading, joining, and initializing. So the difference between dynamic loading and static loading is also easier to get when it's time to load completely (static loading also checks the integrity of the class at compile time). There is a code to prove this. The JVM formally loads a class when the class is used, and the JVM dynamically loads, links, and initializes the first time the class is used.

Java.lang.Class 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.