zuai-logo
zuai-logo
  1. AP Computer Science A
FlashcardFlashcardStudy GuideStudy GuideQuestion BankQuestion BankGlossaryGlossary

Glossary

P

Pre-initialized Strings

Criticality: 2

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.

S

String

Criticality: 3

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

Criticality: 2

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

Criticality: 3

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().