[問題] this與toString的誤用
問題(Question):
我覆寫了一個toString()方法
public String toString(){
// System.out.print(this);
// this.toString();
System.out.print("\n"+"V");
return "abc";
}
其中註解的地方就是程式執行錯誤的地方
我看不懂錯誤訊息
預期的正確結果(Expected Output):
能印出horseA@1fb8ee3
錯誤結果(Wrong Output):
at horse.toString(horse.java:11)
at java.lang.String.valueOf(Unknown Source)
at java.io.PrintStream.print(Unknown Source)
一直重複出現
程式碼(Code):(請善用置底文網頁, 記得排版)
共三部分
1http://pastie.org/1768498
2http://pastie.org/1768502
3http://pastie.org/1768506
補充說明(Supplement):
我是新手
簡單問題請海函
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.123.130.19
推
04/08 01:02, , 1F
04/08 01:02, 1F
→
04/08 01:07, , 2F
04/08 01:07, 2F
→
04/08 01:09, , 3F
04/08 01:09, 3F
推
04/08 01:47, , 4F
04/08 01:47, 4F