Switch to Dark Mode

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

Last Updated : Mar 27, 2025
Discuss
Comments

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

A

String str = 'Hello';


B

String str = new String("Hello");

C

String str = String("Hello");

D

String str = Hello;

Share your thoughts in the comments