TreeMap or HashMap question

Hi,

I noticed that if I use the put method with the string as the parameter for any objectB, I would get that objectB back by using the get function with that string. However, if I use the put method as an objectA as a parameter for any objectB, I would not get back objectB even if objectA all the fields exactly the same. Is there a way to somehow override the checking mechanism like a comparator? Thanks.

[421 byte] By [edisont999a] at [2007-11-27 10:18:18]
# 1

To use a custom object as a key, you must override the following methods in Object

equals()

hashcode()

tjacobs01a at 2007-7-28 16:27:53 > top of Java-index,Java Essentials,Java Programming...