[英]Where string will create object in java when we did concat operation?
I wrote the following;我写了以下内容;
String str1 = new String("railway"); // line 1
String str2 = str1.concat("station"); // line 2
When line 1 executes string will create objects in scp and heap.当第 1 行执行时,字符串将在 scp 和堆中创建对象。
What about the line 2 statement?第 2 行语句呢? In this case also it creates in scp and heap?
在这种情况下,它还会在 scp 和堆中创建吗?
Thanks in advance提前致谢
"railway" and "station" will be in Constant Pool. “铁路”和“车站”将在恒池中。
str1 and str2 will be in heap. str1 和 str2 将在堆中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.