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