服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

?w???p??:java初始化??序


  class bowl {
bowl(int marker) {
system.out.println("bowl(" + marker + ")");
}

void f1() {
system.out.println("ok");
}
}

class cupboard {
bowl b1 = new bowl(1);

static bowl b2 = new bowl(2);

cupboard() {
system.out.println("cupboard()");
}

static bowl b3 = new bowl(3);
}

class table {
table() {
system.out.println("table()");
}
table(string a,int i){
this();
system.out.println("ok");
}
}

public class order {
static cupboard t1 = new cupboard();

static table t2;

bowl t3 = new bowl(10);

void print() {
t3.f1();
}

public static void main(string[] args) {
system.out.println("creating new cupboard() in main");
new cupboard();
system.out.println("creating new cupboard() in main");
order od = new order();
od.t3.f1();
table t4 = new table("aa",1);
}
}

程序

扫描关注微信公众号