equals method contract in JLS

S

stixwix

Hi,
I can't find mention of the equals contract in the Java Languge Spec.
Does anyone know where it is and does anyone know of a searchable
version of this document. (I suppose we shoud all know it so well that
this is pointless!).
Thanks,
Andy
 
S

stixwix

Yes, Sun was a good place to look for a searchable version! (Doh).
And, indeed, the equals contract is not in the JLS. I know it's in the
API for Object but am surprised it's not in the JLS.
 
C

Chris Smith

stixwix said:
I can't find mention of the equals contract in the Java Languge Spec.
Does anyone know where it is and does anyone know of a searchable
version of this document. (I suppose we shoud all know it so well that
this is pointless!).

The most relevant section of the JLS (3rd ed) is 1.3, which states:

"As noted above, this specification often refers to classes of the
Java and Java 2 platforms. In particular, some classes have a
special relationship with the Java programming language. Examples
include classes such as Object, Class, ClassLoader, String, Thread,
and the classes and interfaces in package java.lang.reflect, among
others. The language definition constrains the behavior of these
classes and interfaces, but this document does not provide a
complete specification for them. The reader is referred to other
parts of the Java platform specification for such details API
specifications."

In other words, the JLS doesn't define this. Instead, the contract for
equals is specified in the API specification (also known informally as
api docs, or javadocs) for the Object.equals method.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top