new String 到底创建了几个对象!

String str1 = "hello"; // 创建了一个对象 String str2 = new String("hello"); // 若常量池中已有 hello 则只会在堆中创建一个对象 若常量池中没有 hello 则会在堆中创建一个对象 在常量池中创见一个对象 例如 :String str2 = new String("hell"); // 接着以上的代码 此处 创建了俩个对象 Str
相关文章
相关标签/搜索