What is the purpose of the expression "new String(...)" in Java?
In short the problem is to create a substring from a huge string so the author argues that it is better to use the new String(substring) constructor because string returned by substring() will use the same char[] as parent string, so if we do not use new String() then the huge literal will still be in use. in order to avoid unnecessary huge char[] occupying memory it is better to create new String object with smaller char[] and hence shorter literal. the huge char[] can then be garbage collected But! as I learned literal are never garbage collected!
Garbage collection of String literals
So even though huge char[] is not pointed by any local variable it can still stay in the literal pool hence defeats the purpose of efficiently using memory.