JDK source code reading self-study notes ------- (g) (On a two-dimensional array)

  • The actual development in general use up to two-dimensional array, no matter how high are rarely used
  • Two-dimensional array rarely used, the actual development will be used instead of using container

1, create a two-dimensional array

1          // two-dimensional array initialization 
2          int [] [] = secondDimensional new new  int [. 3] [];
View Code

2, a two-dimensional array assignment

1          // two-dimensional array Assignment 
2          secondDimensional [0] = new new  int [] {1, 2,. 3 };
 . 3  
. 4          secondDimensional [1] = new new  int [] {1, 2,. 3,. 4};
View Code

3, operation of a two-dimensional array Tabular

  • Thinking: the establishment of a one-dimensional array, one-dimensional array into a two-dimensional array to generate tables
  • Note: [] a two-dimensional array is automatically generated no digital mapping
    1          // first data line 
    2          Object [] = {tablesName "ID", "name", "age", "functions", "entry date" };
     . 3  
    . 4          // user data 
    . 5          Object [] = {the userData 1001, "Joe Smith", 22 "teacher", "2010-11-21" };
     . 6  
    . 7          // two-dimensional array initialization 
    . 8          Object [] [] = secondDimensional new new Object [. 3 ] [];
     . 9  
    10          // stored data 
    . 11          secondDimensional [0] = tablesName;
     12 is  
    13 is          secondDimensional [. 1] = the userData;
    14  
    15          // print data 
    16         System.out.println("表格" + Arrays.toString(secondDimensional[0]));
    17         
    18         System.out.println("NUM" + Arrays.toString(secondDimensional[1]));
    View Code

     

Guess you like

Origin www.cnblogs.com/liuyangfirst/p/12391268.html
Recommended