0
When should I use HashMap instead of creating a Class?
It seems that HashMap is less useful and its use may be done with a Class, so why use it?
2 Answers
+ 1
Hasmap is a good collection. Use it when you need associate values to key.
Its easier than create a class because its generic parameters.
An exaple of using map: If you have class A and B , make in class B a Map<Integer,A> what stores A objects by ID. In classB you can search A objects by ID.
+ 1
Thanks!