I really do not understand what is hashtable and iterator even after i read some of the explanation and coding.
without it,i still can write and compile my program.
actually when we have to use it and how to use it?:confused:
can someone point me to the write way?:)
a kind of mapping
maps keys to values
keys and values seem cant be null
Hash table - Wikipedia, the free encyclopedia
Just curious why you are using a HashTable and not the more recent and possibly robust HashMap?
That was actually the point i was going to make, HashMap over HashTable.
HashMap is basically a 1 to 1 function. Key -> Value. The key could be anything (String), not just a number like an array. and that key is pointing at a value. so when you say HashMap.get("key1") it returns value1. and value1 can be any type of object, but for simplicity we can say a String "value1". and when you want to store a new value in a key into the HashMap, HashMap.put(key2, "key2"); and if you want the value in that instance you do a get on the key, key2. any questions still?
Essentially, a hash map (and maps in general) are used in cases where you want to know or remember "for X, what is the Y"?
In case it's useful, I've written various pages about hash maps:
- a basic guide to using hash maps (including an outline of when to use them)
- how hashing works
- how hash functions work: a look at the String hash function works and its implications for other hash functions.
Follow Neil's links. He's good.