Underlying mechanism of String pooling in Java?
问题 I was curious as to why Strings can be created without a call to new String() , as the API mentions it is an Object of class java.lang.String So how are we able to use String s="hi" rather than String s=new String("hi") ? This post clarified the use of == operator and absence of new and says this is due to String literals being interned or taken from a literal pool by the JVM , hence Strings are immutable. On seeing a statement such as String s="hi" for the first time what really takes place