Array Categories:
1, from the array of subscript divided into index array, associative array
Copy Code code as follows:
/* Index array, that is, an array that is usually called/
var ary1 = [1,3,5,8];
Array elements by index, starting from 0 (of course some language implementations start at 1)
An index is actually an ordinal, an integer number
Alert (ary1[0]);
Alert (ary1[1]);
Alert (ary1[2]);
Alert (ary1[3]);
/* Associative array, an array that is accessed as subscript with a non-ordinal type called a dictionary in Python
var ary2 = {};
Access to non ordinal (number), here is the string
ary2["one"] = 1;
Ary2["two"] = 2;
ary2["THR"] = 3;
ary2["fou"] = 4;
2, from the storage of data into a static array, dynamic array
Copy Code code as follows:
static arrays in Java
The length of the array is fixed and cannot be changed, and array elements are indexed by index
Int[] Ary1 = {1,3,6,9};
Dynamic Arrays in Java
The ArrayList implementation in Java is based on array, which says that dynamic arrays are generalized, regardless of how they are implemented.
list<integer> Ary2 = new arraylist<integer> ();
Ary2.add (1);//You can add elements dynamically, and the length of the array changes as well.
Ary2.add (3);
Ary2.add (6);
Copy Code code as follows:
/* JS array belongs to the dynamic array * *
var ary = [];//defines an array with no length specified
Ary[0] = 1;//can dynamically add elements
Ary.push (3);
Ary.push (5);
Alert (Ary.join (","));//Output 1,3,5
JS Array is also an index array and dynamic array, because in essence it is a JS object, embodies the JS dynamic language characteristics. However, the indexed array of JS is not "continuously allocated" memory, so indexing does not bring high efficiency. An array in Java is a contiguous allocation of memory.