Written by the Fiveable Content Team โข Last updated September 2025
Verified for the 2026 exam
Verified for the 2026 examโขWritten by the Fiveable Content Team โข Last updated September 2025
Definition
The .equals(String string) method is used to compare two strings for equality. It checks if both strings have exactly the same characters in the same order.
Related terms
.compareTo(String string): This method compares two strings lexicographically and returns an integer value based on the comparison result.
.startsWith(String prefix): This method checks if a string starts with a specified prefix.
.endsWith(String suffix): This method checks if a string ends with a specified suffix.