构造函数
public class Const {
private Integer a, b, c;//int类型的初始值是0,Integer的初始值是null,所以main方法输出null
public void Const() {//不要粗心大意,去掉void才是构造函数,
System.out.println("构造函数");
a = 3;
b = 5;
this.c = a + b;
}
public void test() {
System.out.println("The value of c :" + c);
}
public static void main(String[] args) {
Const c = new Const();
c.test();
}
}