java array of basic problems

(1) creates an array (the length of the array must be determined):
dynamically created: int [] arr = new int [5]; int arr [] = new int [5];
static creation: data type [] variable name = {value, value, value ...}

(2) multi-dimensional array (two-dimensional array)
three kinds creation method
1. Data Type [] [] = new variable name Data type [m] [n-];
2. Data Type [] [] = new variable name Data type [ m] [];
3. data type [] [] = new variable name data type [] [] elements {{...}, ... {element}, {element} ...};
(. 3) Arrays, relationship with an array of object classes:
arrays, auxiliary class is an array of classes (Arrays.sort (); Arrays.toString () ;)
copy (4) of the array
1.System.arraycopy (...);
2.Arrays.copyOf ();
memory space (5) of the array allocation
insight: https: //www.jianshu.com/p/aa905c079332

Classic example:
int [] = A new new int [2]; // Code. 1
int [] B = new new int [2] {100, 101}; // Code 2
int [] C = {100, 101}; // Code. 3
int [] d; // Code. 4
D = {100, 101}; // Code. 5
int [] E; // Code. 6
E = new new int [] {100, 101}; // Code 7

Do you think the compiler will complain listed code

Answers
at the code 2 and code will compile error maybe 5

Guess you like

Origin www.cnblogs.com/fyscn/p/11920355.html