How many items can be stored in a HashMap object in Java

I know that this is determined by the memory available in the system, and also depending on the good hash function, but in general I would like to know which largest card you used, and if it works well out of the box or the necessary setting so that it worked adequately.

+4
source share
1 answer

A HashMapin Java can have a maximum of 2 ^ 30 buckets for storing records - this is due to the fact that the destination-sheet method used java.util.HashMaprequires the number of buckets to be 2, and since ints are enclosed in Java, the maximum positive value is 2 ^ 31 - 1, so the maximum power of 2 is 2 ^ 30.

, /, HashMap - size() , 2 ^ 31 - 1. - - /, , , LinkedList.

, , 2 ^ 30 , , , . HashMap, - , JVM, ,

+11

All Articles