String s = hello; s = s + world; 执行后原始的String对象内容是否改变

String s = “hello”; s = s + “world”; 执行后原始的String对象内容是否改变? 一 : String s = “hello”; s = s + “world”; 执行后原始的String对象内容是否改变? 因为String是不可改变的类,所以他的所有对象都是不可变的; s 原先指向的对象是内容为hello的对象,然后进行了+操作,此时会创建一个内容为world
相关文章
相关标签/搜索