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?

28th Jun 2017, 7:49 PM
igokra
igokra - avatar
2 odpowiedzi
+ 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.
28th Jun 2017, 8:17 PM
Szabó Gábor
Szabó Gábor - avatar
+ 1
Thanks!
28th Jun 2017, 8:31 PM
igokra
igokra - avatar