Java BASICS (6) JavaSE and javase

Source: Internet
Author: User

Java BASICS (6) JavaSE and javase
1. Array

Concept: a collection of the same type of data. An array is actually a container.

Benefit: You can automatically number the elements in the array from 0 to facilitate operations on these elements.

Format:

① Element type [] array name = new element type [number of elements or array length]; example: int [] arr = new int [5];

②. Element type [] array name = new element type [] {element, element ,....}; example: int [] arr = new int [] {,}; or int [] arr = };

Common exceptions:

①. ArrayIndexOutOfBoundsException: // This exception occurs when you access an index that does not exist in the array.

②. NullPointerException: // when the referenced variable does not point to any object, it is still using it to operate the object. This exception occurs.

③. [I @ c17164 // hash address. @ indicates an integer array.

Appendix 1: Memory Division:

1. Register.

2. Local method area. (Related to the system)

3. Method area.

4. stack memory.

All local variables are stored, and once the scope of the variable ends, the variable is automatically released.

5. heap memory.

Storage is an array and an object (in fact, an array is an object). Every new object is created in the heap.

Features:

1. Each object has a first address value.

2. Each variable in the heap memory has a default initialization value, which varies depending on the type. The integer is 0, the decimal point is 0.0 or 0.0f, boolean false, char '\ u0000 '.

3. Garbage collection mechanism.

 

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.