![](/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.