When JVM loads a class containing a String literal
String str = "hello";
it reads string literal from class file in UTF-8 encoding and creates a char array from it
char[] a = {'h', 'e', 'l', 'l', 'o'};
then it creates a String object from this char array using String(char[]) constructor
new String(a)
then JVM places the String object in String pool and assigns the reference to this String object to str
variable.