Storing Text in Strings
Strings store text and present it to users. The most basic element of a string is a character. A character is a single letter, number, punctuation mark, or other symbol.
In Java programs, a character is one of the types of information that can be stored in a variable. Character variables are created with the char type in a statement such as the following:
char keyPressed;
This statement creates a variable named keyPressed that can store a character. When you create character variables, you can set them up with an initial value, as in the following:
char quitKey = '@';
The value of the character must be surrounded by single quotation marks.
A string is a collection of characters. You can set up a variable to hold a string ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access