Several scenarios in which Java classes are used

Source: Internet
Author: User
Active use (class is initialized)

The flag of whether a class is initialized or not is to assign an initial value to a static variable and execute a static block of code.
Active use is sure to initialize the class.
The following are the active use cases:
1. Create an instance of the class
2. The subclass or implementation class of the class is initialized
3. Accessing static variables or methods of this class
4. Use reflection Class.forName (string className) or Class.forName (string className, True (must be true), ClassLoader ClassLoader)
or direct "class name. Class" To create the Java.lang.Class object for the class.
5. Belongs to the Program entry class (the class where the main method resides before the JVM initializes the class before the Main method call)

Passive use

Other uses other than active use are known as passive use,
such as using Classloader.loadclass (String className) and Class.forName (string className, False (must be false), ClassLoader ClassLoader), the class is not initialized.

Several scenarios in which Java classes are used

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.