What is the word & ldquo; is equivalent to & rdquo; means in Java API?


I'm not sure anyone will know the answer to this question, unless you are responsible for writing the Jave API, but when the Java API says "equals", does it always mean that a.equals(b) evaluates to true, or sometime does it mean a == b is true? I have recently extended a class and wondered if I needed to override a method depending on where or not it used == or .equals. Specifically, I extended javafx.beans.binding.ObjectExpression and was curious about the .isEqualTo(Object other) method. I checked the source (here) and found that this method uses .equals for comparison. I'm curious if I can be confident that when I read things like

"Creates a new BooleanExpression that holds true if this ObjectExpression is equal to a constant value."

that the method is not using the == operator. Although, as I think of it, the API can't possibly mean .equals either, since (for example)

String constant = "constant";
ObjectExpress<String> stringExpression = new MyStringExpression("constant");


will always evaluates to false. So maybe my question should be "when the API says 'equals', does it always refer to the most reasonable way to apply .equal or sometime does it refer to the analogous way to apply ==?"


I think based on the answers I should clarify: this is not a question about the difference between == and .equal. It is about to which the Java API is referring when it uses the English word "equals".

It's clear that you do understand the difference between equals() and ==. So your question is rather philosophical :)

Generally, many APIs use "equals to" in the meaning of equals() and "is the same as" in the meaning of ==. E.g. JUnit has assertion method assertEquals() and assertSame().

However, use your common sense and analyze the language of the doucmentation. Notice in your quoted sentence from API the usage of the indefinite article:

"Creates a new BooleanExpression that holds true if this ObjectExpression is equal to a constant value."

"a constant value" clearly means any constant value, not the same value as the "constant" value. So it is clear that this cannot mean the same as constant.equals(stringExpression).

So take it in this way: when documentation says "equals", take it that it relates to the content of the variable, not to its reference. But use common sense and read the sentence as a whole :)

Does it answer your question? :P