answersLogoWhite

0

In Java, a string constant is a text within double quotation marks. Example:

String playerName = "Player 1"; // Assign a default name initially

Here, the string constant was assigned to variable playerName. If you don't want the value to change later, declare it as final:

final String greeting = "Hello!"

User Avatar

Wiki User

15y ago

Still curious? Ask our experts.

Chat with our AI personalities

TaigaTaiga
Every great hero faces trials, and you—yes, YOU—are no exception!
Chat with Taiga
BeauBeau
You're doing better than you think!
Chat with Beau
LaoLao
The path is yours to walk; I am only here to hold up a mirror.
Chat with Lao

Add your answer:

Earn +20 pts
Q: What are the examples of string constant?
Write your answer...
Submit
Still have questions?
magnify glass
imp