The Array in JAVA
We can define an array by this way
it's a dynamic array,which is needed to be assigned
int num[] = new num[30];
we can access it by this way
num[0] = 10; // The first value of this array
num[1] = 11; // The second value of this array
we can output them by this way
System.out.println("num[0] = " + num[0]);
This is a static array
String stu[] = new String[]{"Jack","Marry","Bob"};
We can get its numbers(个数) by this way
System.out.println("The numbers of this array are:" + num.length);
typical definations
String[] stu = new String[]{"Jack","Marry",‘Bob"’};
invoke an array
a.
for(int i = 0; i < array.length; i++)
Systm.out.println(array[i]);
b.增强for循环
The system will acquire each valus of the arr2 and assign it to arr1,until every value is output.
for (String arr1 : arr2)
System.out.println(arr1);