用户信息
经验: 426
等级:
3 略知一二
资产: 617 华新币
发贴: 164
在线: 391.4 小时
复制本帖HTML代码
高亮 :
今天贴
X 昨天贴
X 前天贴
X
SprinklerSystem类里面定义了soure这一变量
private WaterSource source = new WaterSource();
也就是说source 这个变量属于WaterSource类
然后main程序中System.out.println(sprinklers)会调用
public String toString() {
return
"valve1 = " + valve1 + " " +
"valve2 = " + valve2 + " " +
"valve3 = " + valve3 + " " +
"valve4 = " + valve4 + "\n" +
"i = " + i + " " + "f = " + f + " " +
"source = " + source;
}
这里面"source = " + source;这一句又会调用source这一变量(属于WaterSource类)中的
public String toString() { return s; }
而s的初始值是 Constructed .
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!
”Light thinks it travels faster than anything but it is wrong. No matter
how fast light travels, it finds the darkness has always got there first, and
is waiting for it.”