首先贴出测试用例: package test; import org.junit.Test; /** * Created by Administrator on 2015/9/16. * */ public class TestString { String str1 = "hello quanjizhu"; //若String pool中没有,则创建新对象,并放入String pool String str2 =str1+"haha"; //由于string不可变…
本文转载自 https://www.cnblogs.com/fguozhu/articles/2661055.html Java中String是一个特殊的包装类数据有两种创建形式: String s = "abc"; String s = new String("abc"); 第一种先在栈中创建一个对String类的对象引用变量s,然后去查找"abc"是否被保存在字符串常量池中,如果没有则在栈中创建三个char型的值'a'.'b'.'c',然后在…