What the Java new does

Source: Internet
Author: User
Example: Date date1 = new Date ();
1. Execute this code, the virtual machine first find whether the Date.class file has been loaded, if it has been loaded directly jump to the 3rd step, if not the classpath and relative path lookup, the way to find is determined by ClassLoader.
2. Locate the Date.class file, the virtual machine loads the Date.class file into memory, parses the meta-information such as class and annotations, and the virtual machine guarantees that each Date.class file is loaded only once.
3. Request the memory space in the heap to hold the instance of date for the initialization of the variable (the different instances of the class are different only in the variable part, the method shares the same memory ), and the non-parametric constructor method, date (), is initialized.
4. In the stack, request memory space to hold the Date1 handle variable , assigning the initialized instance handle to the Date1 variable.

What the Java new does

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.