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

angular ui router - 10 digest iterations reached in angularjs when using $state.go -

symfony - InvalidConfigurationException in SecurityExtension.php line 429: No authentication listener registered for firewall "secured_area" -

javascript - Can Piwik report referrer in real time? -