本章考察的是各类型的初始值,和类的初始化过程。
public class day1 {
public static void main(String[] args) {
newclass[] nc = new newclass[1];
for (int i : nc[0].i){
System.out.println("整数初始化默认为:"+i);
}
for (double d : nc[0].d){
System.out.println("浮点数初始化默认为:"+d);
}
for (boolean b: nc[0].bo){
System.out.println("布尔型初始化默认为:"+b);
}
for (char c: nc[0].c){
System.out.println("字符型初始化默认为:"+c);
}
for (String str: nc[0].str){
System.out.println("引用对象型初始化默认为:"+str);
}
for (newclass cls : nc){
System.out.println("引用对象型初始化默认为:"+cls);
}
}
}
class newclass{
static int[] i = new int[1];
static double[] d = new double[1];
static boolean[] bo = new boolean[1];
static char[] c = new char[1];
static String[] str = new String[1];
}