数组的默认值
package test1;
public class ArrayDefaultValue {
static int is[] = new int[5];
static String[] arrs = new String[5];
static Object[] objs = new Object[5];
public static void main(String[] args) {
int n = 1;
for (int i : is) {
System.out.print("is[" + n + "] = " + i + "; ");
n++;
}
System.out.println(n + "\n");
n -= 5;// n=n-5;
for (String arr : arrs) {
System.out.print("arrs[" + n + "] = " + arr + "; ");
n++;
}
System.out.println();
n -= 5;// n=n-5;
for (Object obj : objs) {
System.out.print("objs[" + n + "] = " + obj + "; ");
n++;
}
}
}
========================
result: is = 0; is = 0; is = 0; is = 0; is = 0; 6 arrs = null; arrs = null; arrs = null; arrs = null; arrs = null; objs = null; objs = null; objs = null; objs = null; objs = null;