|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
class Insect {
int i = 9;
int j;
Insect() {
prt("i = " + i + ", j = " + j);
j = 39;
}
static int x1 =
prt("static Insect.x1 initialized");
static int prt(String s) {
System.out.println(s);
return 47;
}
}
public class Beetle extends Insect {
int k = prt("Beetle.k initialized");
Beetle() {
prt("k = " + k);
prt("j = " + j);
}
static int x2 =
prt("static Beetle.x2 initialized");
static int prt(String s) {
System.out.println(s);
return 63;
}
public static void main(String[] args) {
prt("Beetle constructor");
Beetle b = new Beetle();
}
}int k = prt("Beetle.k initialized");[/COLOR]
上述程序中的int k = prt("Beetle.k initialized"); 是将方法的值赋给一个整数型变量k吗
,还是用k调用这个方法(好像调用方法用圆点)。 还有方法括号里的参数是不是起初始化的作用。基本概念混淆,不要见笑。
望 各位高手不吝赐教。先谢谢了。附 以上程序来自 "think in java" |
|