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

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -