Given that String is such a useful and frequently used class, it has special syntax (via string literal representation: the text inside "" ) to create instances of it, but semantically these two are equivalent:
String s = "Hello";
Behind the hood, both forms are not 100% equivalent, since the syntax using "" tries to reuse the rows from the Java string pool, while explicit instantiation with new String("") will always create a new object.
But make no mistake, neither the syntax will give a reference to an instance of the object, nor strings are considered primitive types in Java and are instances of the class, like any other.
source share