![](/img/trans.png)
[英]Where is the new Object of String created when we concat using + operator
[英]Where string will create object in java when we did concat operation?
我写了以下内容;
String str1 = new String("railway"); // line 1
String str2 = str1.concat("station"); // line 2
当第 1 行执行时,字符串将在 scp 和堆中创建对象。
第 2 行语句呢? 在这种情况下,它还会在 scp 和堆中创建吗?
提前致谢
“铁路”和“车站”将在恒池中。
str1 和 str2 将在堆中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.