11th days: array, 11th days group
1: How to save multiple data: Array
2: Array
2.1: stores multiple data of the same type. That is, it can represent multiple basic data types or multiple referenced data types, but the array represents the same type of data, that is, the array cannot contain multiple data types, for example, an array of the int type cannot contain data of the double type. The data address in the memory is continuous.
Feature: when creating an array, you must determine the size of the array. The size of the created array cannot be changed. This is also the confirmation of the array.
2.2: Syntax: []
Data Type [] array name.
Type [] array name = new type [array size]; array name = {param1, param2 ...}
Type [] Name = {param1, param2 ,...};
Type [] Name = new type [] {param1, param2 ...};
Note: int [] array = new [5];Indicates that the size of the array is 5.And the subscript is from 0So the maximum subscript is 4.; Calculation method: array. length-1,Note that the length of the array. lengthIs an attribute rather than length ()One Method
2.3: array Traversal
1: Use a loop
2: Use an enhanced for loop. In this way, only the values in the array can be obtained, but the subscript of the array cannot be used.
For (data type variable name: array to be traversed)
{Enter the variable name directly}
1 int [] b = {1,2,3,4,5};2 for (int i : b) {3 System.out.println(i);4 }