JavaSE进阶

3、String对象的创建

String str = “hello”;

String  s1 = new String();   //  本质上  this.value = new char[0];

String  s2 = new String(String original);  //this.value = original.value;

String  s3 = new String(char[] a);  //this.value = Arrays.copyOf(value, value.length);

String  s4 = new String(char[] a,int startIndex,int count)

.......

4、字符串对象是如何存储的

字符串常量存储在字符串常量池,目的是共享

字符串非常量对象存储在堆中。