Computer Applications

How do you create strings implicitly and explicitly?

Java String Handling

6 Likes

Answer

To create a string implicitly, we write a series of characters enclosed in double quotes. After doing so, the Java compiler implicitly creates an object of the String class and assigns it the value written in double quotes.
For example,
String day = "MONDAY";

To create a string explicitly, we use the keyword — new. There is a constructor in the String class that accepts a string as a parameter and creates a unique string.
For example,
String day = new String("MONDAY");

Answered By

4 Likes


Related Questions