for Kotlin collections that are indexed by `Int` (...
# getting-started
y
for Kotlin collections that are indexed by
Int
(such as
List
), is
Int.MAX_VALUE
the maximum number of elements they can store?
e
in theory. a
List
implementation could contain more than
Int.MAX_VALUE
elements (the ones beyond that won't be indexable, but they might exist). however, the typical ones are backed by arrays, and while neither Kotlin nor the JVM document what the maximum array size is, most code assumes it's somewhere near
Int.MAX_VALUE
(e.g. https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java#L589)
👍 1
y
thank you! I had a difficult time finding this info