3 ms·
Can someone please explain how this is possible, when all the java collections have "int size()" and the max value of a java int is 2,147,483,647?
by thrownaway2424 14y ago
Can someone please explain how this is possible, when all the java collections have "int size()" and the max value of a java int is 2,147,483,647?
- _delirium 14y agoCollections are allowed to grow larger than size() can handle. The documentation for size() says: > If this collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
- thrownaway2424 14y agoI see, thanks for pointing it out. I always considered it a fundamental limitation of collections, because all or almost all of them are array-backed, and array indices in java are int, therefore the collections are generally limited to 2^31 items.
- omaranto 14y agoDoes the term "array-backed" include the possibility of using an array of arrays? That would get you up to about 2^62...