本章考察的是各類型的初始值,和類的初始化過程躬审。
public class day1 {
public static void main(String[] args) {
newclass[] nc = new newclass[1];
for (int i : nc[0].i){
System.out.println("整數(shù)初始化默認(rèn)為:"+i);
}
for (double d : nc[0].d){
System.out.println("浮點(diǎn)數(shù)初始化默認(rèn)為:"+d);
}
for (boolean b: nc[0].bo){
System.out.println("布爾型初始化默認(rèn)為:"+b);
}
for (char c: nc[0].c){
System.out.println("字符型初始化默認(rèn)為:"+c);
}
for (String str: nc[0].str){
System.out.println("引用對(duì)象型初始化默認(rèn)為:"+str);
}
for (newclass cls : nc){
System.out.println("引用對(duì)象型初始化默認(rèn)為:"+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];
}