Introduction to Java Basics essay (6) version Javase

Source: Internet
Author: User

1. Arrays

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

Benefit: The elements in the array can be automatically numbered starting with 0, allowing them to be manipulated.

Format:

①. Element type [] Array name = new element type [element number or array length]; Example: int[] arr = new INT[5];

②. Element type [] Array name = new element type []{element, Element, ....}; Example: int[] arr = new int[]{3,5,1,7}; or int[] arr = {3,5,1,7};

Common exceptions:

①.arrayindexoutofboundsexception://This exception occurs when an index that does not exist in the array is accessed.

②.nullpointerexception://When a reference variable does not have any entities pointing to it, it is also used to manipulate the entity. The exception will occur.

③.[[email protected]//hash address, @ The front section represents an array of integers.

Attached: Partition of Memory:

1. Register.

2. Local method area. (In connection with the system)

3. Method area.

4. Stack memory.

Stores all local variables, and once the scope of the variable belongs to the end, the variable is automatically freed.

5. Heap memory.

Storage is an array and an object (in fact an array is an object) that is usually built in the heap.

Characteristics:

1, each entity has an initial address value.

2, each variable in the heap memory has a default initialization value, which differs depending on the type. Integers are 0, decimals are 0.0 or 0.0f,boolean false,char ' \u0000 '.

3, garbage collection mechanism.

Introduction to Java Basics essay (6) version Javase

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.