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