In general, you should use the string literal notation when possible. In terms of good coding practice: do not use = to check for String equality, use.
String str4 = new String('Hello World!!') String str3 = new String('Hello World!!') In the following code, 2 different objects are created and they have different references: In this example both string literals refer the same object: String s='Hello World!!' may reuse an instance from the string constant pool if one is available (String Pool is a pool of Strings stored in Java heap memory ). It is an individual instance of the class. When you use new String( 'Hello World!!' ), it explicitly creates a new and referentially distinct instance of a String object. Both expression gives you String object, but there is subtle difference between them.