What is the correct way to declare a String in Java?

Last Updated :
Discuss
Comments

What is the correct way to declare a String in Java?

String str = 'Hello';


String str = new String("Hello");

String str = String("Hello");

String str = Hello;

Share your thoughts in the comments