-
HashMap visual example
Hi I'm obligated to use the hashmap class to implement a backgammon game and I have the following given code:
public Map<PointType,List<Color>> getPoints();
It's given in Map but we're supposed to use a HashMap:P
Can anyone explain or describe how a Map or a Hashmap is virtually.
e.g.
a hashtable can be described as non-sequent places in memory that contain certain data allocated with the help of a hash function.I simply can't get it as a picture in my head at least after reading the API.
-
Well imagine an array with methods, without fixed size however, it expands as you add elements to it.
With a HashMap you can add as many items as you want, and each item has its own key. So you add them in pairs, using the put() method. Then when you invoke the get method, you add a key as an argument, and it will return whatever value is associated with that key.
This post really doesnt belong here, in my humble opinion.