What is HashMap | SoloLearn: Learn to code for FREE!


What is HashMap

9/17/2016 10:01:04 PM


3 Answers

New Answer


In a Hashtable, instead of accessing elements with an index number (like in arrays for example), you access them with their key (which can be a number, a string, etc.). For example, here we create a new Hashtable dictionary, insert the key/value pair "blanc"/"white", and display the item with key "blanc": Hashtable dictionary = new Hashtable(); dictionary.put("blanc", "white"); System.out.println(dictionary.get("blanc")); A HashMap is almost like a Hashtable, the only differences being that it accepts null as value or key, and it is not thread-safe.


just like an ArrayList but instead of indexing elements using Integers , You can use e.g Strings or other types ... e.g. HashMap hm=new HashMap<String,String>();


Hashtable? What's that?