Java Basic Concepts--arrays and memory control

Source: Internet
Author: User

Question 1:java How does the memory be allocated in the process of declaring an array?

Build an array variable in the stack memory, and then build an array object in the heap memory. For detailed memory allocation details, it depends on whether the initialization is a dynamic initialization of an array or an array static initialization.

What are the initialization methods for the problem 2:java array?

Two types: dynamic initialization and static initialization.  Dynamic initialization refers to specifying only the length of an array, without specifying the elements of each array. Static initialization refers to each element of the specified array in detail.


What is the difference between an array of basic types of 3:java and an array of application types, and the memory allocation mechanism at initialization time?

the basic type array of Java assumes that no element values are declared, then there will be default values, and the memory space allocated in the Java heap memory by the primitive type array is contiguous.

The Java application type array assumes that no element values are declared. Then the value of the array element is NULL, and the memory space allocated in the Java heap memory by the array of the applied type is not contiguous: Because each element object is generated in detail.



The array reference variable exists in the stack memory. The array object exists in heap memory.

Java Basic Concepts--arrays and memory control

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.