Static code block loading problem during Java EE initialization

Source: Internet
Author: User

1. When you run a class using the Java.exe command
Java.exe person
2. When you create an object of a class
Person P=new person ();
3. Accessing static member variables in a class (Assignment/Get value)
System.out.println (Person.classname);
4. Accessing static member methods in a class
Person.method ();
5. When you create a subclass object of a class
Student s=new Student ();
6. Use reflection to force the creation of a Java.lang.Class object for a class or interface
System.out.println (Person.class);//(static code block not loaded)

The sixth method does not complete the three-step load of the class during the reflection process (load, join, initialize), so static blocks of code in the class cannot be executed, and the rest of the methods can implement static blocks of code.

Static code block loading problem during Java EE initialization

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.