Why can't I have more than 2 billion items in my array?

John Zukowski

Arrays are limited to have integer (int) index variables. It is a compile-time error to try to use a long. In addition, since you cannot use the value 2,147,483,648 as a constant (so your array would be indexed from 0 to 2,147,483,647), your array is limited to have at most 2,147,483,647 (0x7fffffff) items in it, having a max index of 2,147,483,646 (0x7ffffffe). Of course, you'll probably run out of memory if you try to create an array that large without increasing the default memory size.