java - Create New Strings in normal memory and in string pool -


if example:

string str1 = “abc”; string str2 = new string(“def”); 

then,

case 1: string str3 = str1.concat(str2) go in heap or pool?

case 2: string str4 = str2.concat(“hi”) go in heap or pool?

in java, whichever string u create using new keyword created in heap memory. if create string without using new, created in string pool , called string constant. there 1 copy of string constant pool value means duplicates wont there in string pool.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -