top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Which is better, to have a HashMap with large number of records or k number of small HashMaps in Java?

+4 votes
369 views
Which is better, to have a HashMap with large number of records or k number of small HashMaps in Java?
posted Sep 21, 2013 by Arvind Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

It depends on the different scenarios on which hashmap is used:-
1. If the objects in the hashMap are same then there is no point in having different hashmap as the traverse time in a hashmap is invariant to the size of the Map.
2.If the objects are of different type like one of Car class , other of Truck class etc then also one can have single hashmap but different hashmap would score over it as it increasesreadability of the code.

answer Sep 22, 2013 by Vinay Shukla
...