java - Where the "Hello" will store in String Constant Pool or Heap? -


this question has answer here:

we know string literals in java programs, such "abc", implemented instances of string class , goes string constant pool. question : "hello" literal store in below case?

string str=new string("hello"); 

if literal goes "string constant pool" intern method do?

string literals in code go directly sring pool. calling intern() on them nothing. intern() make sense in cases dinamically constructing strings (in runtime, not compile-time). in cases calling intern() instruct jvm move variable string pool future usage.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -