为什么说new一个String后创建了两个对象?是在常量池中new了一个和一个引用对象吗
new String("hello")如果字符串池中没有“hello”,JVM就会在字符串池中创建一个“hello”的对象,然后new String又会在堆中创建一个对象,将"hello"拷贝到这个新创建的对象中。
参考一下在个博客,关于String问题讲得比较详细。https://blog.csdn.net/baidu_37107022/article/details/75648066