数组注意事项;
1.数组创建后,没有赋值,有默认值,byte,shor,int,long,double 的值为0. String null,boolean false
public class ArrayDetail {
public static void main (String[] args){
short[] arr1 = new short[3];
int[] arr2 = new int[4];
double[] arr3 = new double[2];
boolean[] arr4 = new boolean[3];
String[] arr5 = new String[5];
for (int i= 0; i < arr1.length; i++ ) {
System.out.println(arr1[i]);
}
for (int i= 0; i < arr2.length; i++ ) {
System.out.println(arr2[i]);
}
for (int i= 0; i < arr3.length; i++ ) {
System.out.println(arr3[i]);
}
for (int i= 0; i < arr4.length; i++ ) {
System.out.println(arr4[i]);
}
for (int i= 0; i < arr5.length; i++ ) {
System.out.println(arr1[i]);
}
}
}
2.数组的下标是从零开始