String 常量池的一些注意事项

咱们都应该知道,new出来的对象会放在堆中分配空间,String 也是同样:String s = new String("s"); 而String直接引用的值都放在常量池中,但对String类型的“+”运算值得弄清楚: public static void test1() { String s = "ab"; String a = "a" + "b"; System.out.pri
相关文章
相关标签/搜索