Which String methods come up most often in Java interviews, and what does each one actually do?
The set is smaller than people expect, and knowing exactly what each one returns is worth more than memorising the whole API. length() counts UTF-16 code units, so an emoji counts as two. charAt(int) returns a char and throws StringIndexOutOfBoundsException out of range. isEmpty() tells you whether there are no characters at all. equals compares contents and is null-safe on the receiver; equalsIgnoreCase folds case using the default locale rules. compareTo returns the lexicographic difference and is what sorting uses.
The searching methods split into two families. indexOf, lastIndexOf, contains, startsWith and endsWith work on literal characters and substrings. matches works on a regular expression and must match the entire input, which is why "abc123".matches("[a-z]+") is false. replaceAll and replaceFirst also take regular expressions, while replace takes literal text.
The transforming methods — trim, strip, toUpperCase, toLowerCase, substring, concat — all return new Strings because Strings are immutable. strip is Unicode-aware, unlike the older trim which only removes characters below U+0020.
Finally the parsing family: split with its overloads, String.join, valueOf, and the boxed-type parsers such as Integer.parseInt. Knowing that split takes a regular expression and that valueOf(null) means the word "null" are the two details that separate a candidate who has used these in anger from one who has only read the list.