equals()

A method used to test whether two objects have equal content.

What does equals() do in Java?

equals() — A method used to test whether two objects have equal content.

class AnswerChecker {
    boolean isYes(String answer) {
        return answer.equalsIgnoreCase("yes");
    }
}

Level: Apprentice · More Java terms at this level

Updated

In other subjects