I understand that using new String(..)
will create a new object, where as literals will be stored in string pool and reused.
Is there any real time use case for this? When would I need to use new String(..)
?
Why is the String.valueOf(char[])
or String.valueOf(byte[])
is designed to create new String object? Is there no way you can programmatically add the char[]
to the string pool?