Home > Java > javaTutorial > How to create objects in java

How to create objects in java

王林
Release: 2023-05-21 21:58:33
forward
1378 people have browsed it

1. Check whether the class is loaded.

When the virtual machine encounters the new instruction, it first checks whether the parameters of the instruction can be located as a symbol reference of a category in the constant pool, and checks whether the category represented by the symbol reference is loaded, analyzed and initialized. . Otherwise, perform the class loading process.

2. Allocate memory for the target.

After completing class loading, the virtual machine begins to allocate memory to the target and determines the required memory size. Just allocate the necessary memory on the heap.

3. Initialize the allocated storage space with a zero value.

After the memory allocation of the object is completed, the memory space of the object needs to be initialized to zero to ensure that the object can be used directly even if it has no initial value.

4. Make other settings for the audience.

After allocating memory space and initializing the zero value, the virtual machine also needs to make other necessary settings for the object. The setting place is located in the object header, including the class to which the object belongs, class metadata information, and object hashcode. , GC agent age and other information.

5. Execute the init method.

After performing the above steps, even if the object in the virtual machine is successful, the Java program still needs to implement the init method, because the object at this time is only an initialized zero value, and there is no real initialization based on the code in the program. value, so after calling the init method, this object can really be used.

What are the commonly used java frameworks

1. SpringMVC, Spring Web MVC is a lightweight Web framework based on Java that implements the request-driven type of Web MVC design pattern.

2.Shiro, Apache Shiro is a security framework for Java.

3.Mybatis, MyBatis is an excellent persistence layer framework that supports ordinary SQL queries, stored procedures and advanced mapping.

4.Dubbo, Dubbo is a distributed service framework.

5.Maven, Maven is a project management and build automation tool.

6.RabbitMQ, RabbitMQ is a high-concurrency and high-reliability AMQP message queue server implemented in Erlang. 7.Ehcache, EhCache is a pure Java in-process caching framework.

The above is the detailed content of How to create objects in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template