2.4

String Methods

AP Computer Science A

Strings are objects — and they're immutable

String indexing

Essential String methods

length()

substring(int from, int to)

substring(int from)

indexOf(String str)

equals(String other)

compareTo(String other)

Combining methods — real exam patterns

Get the first character

Get the last character

Check if a string starts with something

Reverse traversal of characters

Extract and build

Trace practice — the full workout

String concatenation with +

AP Exam Tips

Common Mistakes

Key Vocabulary