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

前端 未结 23 2936

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条回答
  •  猫巷女王i
    2020-11-22 14:33

    String is one of the special classes in which you can create them without the new Sring part

    it's the same as

    int x = y;

    or

    char c;

提交回复
热议问题