package TestPackage;
class WaterSource {
private String s;
WaterSource() {
System.out.println("WaterSource()");
s = "Constructed";
}
public String toString() {
return s;
}
public class SprinklerSystem {
private String value1,value2,value3,value4;
private WaterSource source = new WaterSource();
private int i ;
private float f;
public String toString() {
return
"value1 = " + value1 + " " + "value2 = " + value2 + " " + "value3 = " + value3 + " " +
"value4 = " + value4 + "\n" + "i = " + i + " " + "f = " + f + " " +
"Source = " + source;
}
}
public static void main(String[] args) {
SprinklerSystem sprinklers = new SprinklerSystem();
System.out.println(sprinklers);
}
}
main方法第一句SprinklerSystem sprinklers = new SprinklerSystem(); eclipse报出的错是No enclosing instance of type WaterSource is accessible. Must qualify the allocation with an enclosing instance of type WaterSource (e.g. x.new A() where x is an instance of WaterSource).
请问这是为什么?
我是偶哦
相关分类