1

This question I am asking on the basis of my research as I was going through the source code of hashmap in decomplier , please advise Can I also create my own custom HashMap as the java HashMap is , Please advise how Can I create my own custom HashMap named MyMap..!1

4
  • Why would you want to do that? What feature is the HashMap missing? Commented Aug 5, 2012 at 16:52
  • For my own research and understanding..this is also a challenge to come up with own custom HashMap..!! Commented Aug 5, 2012 at 16:53
  • This question has been asked several times in the last few days, so I've flagged this as duplicate. See stackoverflow.com/questions/4072127/… for an example which has an accepted answer. Commented Aug 5, 2012 at 16:55
  • Knock yourself out. Commented Aug 5, 2012 at 20:03

2 Answers 2

6

If you want to write your own implementation of HashMap, simply implements the Map interface and implement its methods the way you want:

public class HashMap<K,V> implements Map<K,V>, Cloneable, Serializable {
    @Override
    clear() { // My implementation
    }
    // Other methods
}

You may also want to extend the AbtractMap abstract class that provides a skeletal implementation of the Map interface, to minimize the effort required to implement this interface.

Sign up to request clarification or add additional context in comments.

Comments

1

you can see the source code for HashMap in java and write of your own.

go check this linkHashMap java doc

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.