Why does not include a generic equals()?

Why does the the Generics "Enhancement" of java not include a generic equals

method?

I am not strong on Generics; however something like:

public boolean equals(<?>)

It seems to me that a wild card based equals would be extremely handy.

It would be open enough to allow the standard use and overriding; while at the

same time allowing for cast-less checks for equivalence over large sets of data

objects. This would allow for faster sorting and data manipulation.

Am I missing something?

[551 byte] By [paulkosslera] at [2007-11-26 17:04:59]
# 1
Indeed I think you are missing something:The class Object has a methodboolean equals(Object obj) that is inherited by every class and therfore does exacly do what you are requesting.
Christoph.Nievergelta at 2007-7-8 23:32:44 > top of Java-index,Core,Core APIs...
# 2

I understand that the standard Object.equals(Object obj) method which has

been there since Java 1.0.However, I am specifically concerned with being

able to "Genericize" the Equals method to specifically remove the down cast

required before being able to accessing any object specific elements. Casts

are expensive and it slows down large list (1k+ objects) considerably.

I could be confused about how Generics work, however, the constructor and

definition of java.lang.Object has been genericized so it makes sense to have

this option too.

paulkosslera at 2007-7-8 23:32:44 > top of Java-index,Core,Core APIs...
# 3
How are casts expensive?I don't imagine that there's any way to do what you want without breaking backward compatibility.
dannyyatesa at 2007-7-8 23:32:44 > top of Java-index,Core,Core APIs...
# 4
http://www.javaworld.com/javaworld/jw-12-1999/jw-12-performance.htmlExplains the cost of casting
paulkosslera at 2007-7-8 23:32:44 > top of Java-index,Core,Core APIs...
# 5
I figured out why it is not included now that I understand Erasure better. At runtime this concept is negated. I am too used to C++ Templates which can be used in this manor.Thanks anyway.
paulkosslera at 2007-7-8 23:32:44 > top of Java-index,Core,Core APIs...
# 6
> Explains the cost of casting... 7 years ago
dannyyatesa at 2007-7-8 23:32:44 > top of Java-index,Core,Core APIs...