Bit confused between differences of HashMap and ArrayList. I know both are unsynchronized and are much faster than Hastable and Vector. Can you please expalin me the exact difference between the two.
HashMap is a collection of key and value pairs similar to Hashtable. But , it supports null and one duplicate key ArrayList is a collection of objects similar to Vector. It is growable array.
Thanks for reply. But can you expalin in depth on " it supports null and one duplicate key". It would be great you can expalin me iwth example to get clear picture.
Maps do not support duplicate keys, so HashMap also does not support duplicate keys. So "it supports one duplicate key" is wrong.
"It supports null" means that you can use null as a key or value. Hashtable does not support null for keys or values (you'll get a NullPointerException if you try to use null as a key or value in a Hashtable).
I would like to know what are the similarities between ArrayList and HashMap, I was asked in an interview this questions. I mean I read somewhere that both can be used for faster iteration and random access. I would like to know if there are more similarities out there between ArrayList and HashMap.