- 最後登錄
- 2024-3-28
- 在線時間
- 7333 小時
- 註冊時間
- 2008-11-3
- 閱讀權限
- 30
- 精華
- 0
- UID
- 5255050
- 帖子
- 3470
- 積分
- 3983 點
- 潛水值
- 62440 米
| 發表於 2018-10-25 09:44 AM|顯示全部樓層 如果發覺自己無法使用一些功能或出現問題,請按重新整理一次,並待所有網頁內容完全載入後5秒才進行操作。 本帖最後由 kwj 於 2018-10-25 09:45 AM 編輯
個人的想法還是一樣,在 CharSequence 上有 toString() 是為了提示開發者有可能有必要實作它。
如果 IDE 沒有自動跑出來,那我認為問題應該是問「為什麼 IDE 沒有跑出提示」,而不是問「為什麼 CharSequence 需要提供 toString() 介面」。
另外,從 CharSequence 的文件中也可以看到以下的描述:
This interface does not refine the general contracts of the equals and hashCode methods. The result of comparing two objects that implement CharSequence is therefore, in general, undefined. Each object may be implemented by a different class, and there is no guarantee that each class will be capable of testing its instances for equality with those of the other. It is therefore inappropriate to use arbitrary CharSequence instances as elements in a set or as keys in a map. ... |
|