Java Strings: “String s = new String(”silly“);”

前端 未结 23 2459

I\'m a C++ guy learning Java. I\'m reading Effective Java and something confused me. It says never to write code like this:

String s = new String(\"silly\");         


        
23条回答
  •  孤街浪徒
    2020-11-22 14:24

    CaseInsensitiveString is not a String although it contains a String. A String literal e.g "example" can be only assigned to a String.

提交回复
热议问题