Which two method you need to implement for key Object in HashMap ?
Answers
1. equals() and 2. hashcode
Class inherits methods from the following classes in terms of HashMap
java.util.AbstractMap
java.util.Object
java.util.Map
and there are constructors and class methods are there( no need to mention here)
but few of them are :
boolean containsKey(Object key)
This method returns true if this map contains a mapping for the specified key
V get(Obect key)
This method returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
Set<K>keySet()
V put(K key,V value)
V remove(Object key)
Collection <V> values()
etc
Now to implement methods of a class who's reference we want to use as Key, we need to override equals() and hashcode() as these methods help to retrive the stored values. there are lots of inner concept to understand to implementation and how actually its work,its took more pages =D which is boring and not to the point question =D but hope it ll help you :)