What is the purpose of the expression “new String(…)” in Java?

后端 未结 9 1065
迷失自我
迷失自我 2020-11-22 02:39

While looking at online code samples, I have sometimes come across an assignment of a String constant to a String object via the use of the new operator.

For example

9条回答
  •  醉酒成梦
    2020-11-22 03:09

    The sole utility for this constructor described by Software Monkey and Ruggs seems to have disappeared from JDK7. There is no longer an offset field in class String, and substring always use

    Arrays.copyOfRange(char[] original, int from, int to) 
    

    to trim the char array for the copy.

提交回复
热议问题