The point of the data is 100. The integer variable definition has no array: int i1; int i2int i3
Define int I [100] with array;
Array definition: int I [100]; It's just a pseudo code, just a (1) one-dimensional array with meaning.
One-dimensional arrays can store tens of millions of data, and the types of these data are exactly the same. To use java arrays, you must go through two steps: declaring arrays and allocating memory to arrays. The first declarative form declares a one-dimensional array: data type array name [] = null; Memory not allocated to array: array name = new data type [length]; Declarative Form 2 declares a one-dimensional array: data type [] Array name = null.
(2)java data types are divided into two categories: 1. The basic data types int and long are themselves specific content reference data types: arrays, classes and interfaces.
Reference conveys the right to use a memory, a memory space, which may be used by many people at the same time.
2. Case declaration array
In the declaration format of an array, the data type is the data type of the array elements. Commonly used array names such as plastic, floating-point and character are used to unify the names of this group of elements with the same data type. After the same array declares variables, the naming rule is actually to save the name of this array in the stack memory, and the memory needed by the array needs to be configured in the stack memory. Fixed production tells the compiler how many elements to store in the declared array, while new commands the compiler according to the length in parentheses.
The basic data type even reading has its default value: int 0;; As long as it is a reference data type, the default value is null case.
Declare an array when allocating memory space. Declare an array with no memory data type. Array name [] = new data type [number] intscore [] = newint [10]; Declare a plastic array score with the number of elements of 10, and at the same time set a time limit for using java according to the memory space. Because the plastic data type occupies 4 bytes, the whole array score can save 10 elements. So the memory occupied by the above example * * * is 4* 10=40 bytes.
(3) Access to the array
The representation of elements in an array can be accomplished by using indexes. The array index number of java starts from 10. Take the plastic array of score[ 10] as an example. Score[0] means that the first element is down, and the last one is score[9].
(4) Obtaining the array length In java, obtaining the array length (that is, the length of array elements) can be accomplished by using the array name. Length, returns an int data.
(5) The array before static initialization is dynamically initialized, and all contents are not specified in the array declaration, but appear in the form of default values. Static initialization refers to specifying specific contents for an array directly after it is declared. If you want to assign an initial value to the array directly when you declare it, you can do it with braces, as long as you add the assignment of the initial value after the life format of the array. Data type array name [] = {initial value 0, initial value 65438.
Example sorting, commonly used sorting in operation, from big to small.
Don't be confused by the value of I at this time if (score [I] >; score[j]){
In contrast, the main knowledge of this step is actually sorted according to the value of J after completion.
(6) Two-dimensional array
Two-dimensional arrays are declared in a similar way to arrays, and the keyword new is also used for memory allocation.
In fact, the format of declaring and allocating memory is as follows: dynamically initialize the data type array name [] []; Array name = new data type [number of rows] [number of columns];
Declare and initialize the array data type array name [] [] = new data type [number of rows] [number of columns]; Static initialization
(7) Storage statement of two-dimensional array The two-dimensional array score also opens up a memory space, int score [] [] = new int [4] [3]; The total data score can store 4*3= 12 elements. In java, the space occupied by int data type is 4 bytes, so the memory occupied by plastic array is 4* 12=48 byte instance.
(8) Static initialization of two-dimensional array
The space will only be opened when it is used, and it will not be opened when it is not used (the red part). Multidimensional arrays are generally only understood by two-dimensional arrays and three-dimensional arrays.