toString()为什么不起作用
public class Cleanser{
private String s = "Cleanser";
public void append(String a){s += a;}
public void dilute(){append(" dilute()");}
public void apply(){append(" apply()");}
public void scrub(){append(" scrub()");}
public String toSring(){return s;}
public static void main(String[] args){
Cleanser x = new Cleanser();
x.dilute();x.apply();x.scrub();
System.out.println(x.toString());
}
}输出时,toString()方法用了和没用一样,为什么
------解决方案-------------------- public String toString(){return s;}你搞笑啊
------解决方案--------------------这是你自己写的 public String toSring(){return s;} 你写的是Sring不是String'