java strings:指向“字符串s = new s = new String(“ silly”)”
問題1:為什麼使用“必要的新caseinsensitivestring(...)”的用法是“必要的?”
Question 2: Adapting CaseInsensitiveString to behave like String
While the default behavior of CaseInsensitiveString necessitates the use of its constructor, there are potential avenues to mimic the simplified syntax of the built-in String class.
With Extension:
Extending String would allow CaseInsensitiveString to inherit its behavior.
Overriding the static factory method of String would enable direct instantiation from literals.
However, this approach tightly couples caseinsensitivestivesting to string類,限制其靈活性並引入潛在的維護問題。 沒有擴展:
static方法可以實現靜態的方法。在提供更方便的語法時,caseinsensitivestring從字符串類中的獨立性進行初始化。免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3