views:

91

answers:

1

The Object class has a number of methods such as equals, hashCode, notify, wait etc.

What methods do you think are missing from the Object class and why? Are there any additional methods you wish it had?

+3  A: 

I don't think it should have any extra methods... in fact, I think various methods that are there shouldn't be there in the first place.

One problem in Java is that a lot of types (such as HashMap) always use the hash code and equality methods on the keys directly - it would be much better if Java had an interface like .NET's IEqualityComparer<T> that anything wanting to perform hashing/equality comparisons could delegate to.

Jon Skeet
You can get at the "bare" hash code using `System.identityHashCode()` in Java.
Joachim Sauer
I tought System.identityHashCode() was there to get this bare hascode anyway?
penpen
Doh - thought this was a .NET question. Will edit :)
Jon Skeet
@Jon Skeet: I've just read your article. From one hand you talk about really reasonable things but from another I think it can enlarge java entry threshold.
Roman