Java learning acquaintance array third day

/ * 
* Array is in memory continuously storing the same data type spatial 
* using an array to declare an array, and then create an array, allocate memory to the array 
length once declared * array can not be changed during the procedure existence 
* declare an array of methods: Data type [] array name 
* sub-arrays and dynamic arrays static arrays 
* * / 
public  class Demo3 {
     public  static  void main (String [] args) { 
        System.out.println ( "Creating dynamic arrays ---- ----- - " );
         // creates an array of dynamic initialization, each element of the array is initially the default 0 
        int [] = ARR new new  int [. 5]; // [number here indicates the length of the array]
         // array of direct print output , the display memory address of the array 
        System.out.println (ARR);
         // get the value of the array elements, the array name [array subscript], calculated from the array subscripts 0, the maximum number of array elements the subscript -1 
        intARR = NUM [0 ]; 
        System.out.println (NUM); 
        // change the value of array element 
        ARR [0] = 10 ; 
        System.out.println (ARR [ 0 ]); 
        System.out.println ( "- ---- ----- create static arrays " );
         // static arrays create a data type array data type name = [] elements {1, .....} element 2 
        int [] = arr2 is new new  int [ ] {1,2,3,4,5 }; 
        System.out.println (arr2 is); 
        // Get array elements and change the static and dynamic array of the same 
        System.out.println (arr2 is [. 1 ]); 
        arr2 is [ 2 ] = 10 ;
         // static arrays may be abbreviated as: data type [] = {array name element 1, element 2 .....}
         // can write separate static array shorthand
        int [] = {10,20, 30,40 ARR3 };
         // get the length of the array with the length property 
        System.out.println ( "arr length of the array is" + arr.length); 
        
    }

 

Guess you like

Origin www.cnblogs.com/vxiao2/p/11479160.html