Glossary
Pre-initialized Strings
Strings created using double quotes (e.g., `String s = "text";`), which are often more efficient as Java can reuse existing string literals from the string pool.
Example:
When you write String color = "blue";, you are creating a pre-initialized String, which Java might optimize by pointing to an existing "blue" in memory.
String
A fundamental data type in Java that represents a sequence of characters, used for storing and manipulating text.
Example:
In String game = "Minecraft";, "Minecraft" is a String value.
String Constructor
A method used with the `new` keyword (e.g., `new String("text")`) to explicitly create a new String object in memory, guaranteeing a distinct object even if the content is identical to an existing string literal.
Example:
Using String secret = new String("password"); employs the String Constructor, ensuring that secret is a brand new object in memory, separate from any other "password" string.
String class
The built-in Java class (`java.lang.String`) that all String objects are instances of, providing numerous methods for text manipulation.
Example:
To check if a user's input is empty, you might use a method from the String class like .isEmpty().