In this case, the restriction will be due to the limitations of the Java Virtual Machine - this is a memory limit.
Experienced I determined that the maximum array size on my machine (java 8) is
int[] array = new int [Integer.MAX_VALUE - 5];
But nobody forbids us to wrap arrays in a class and get:
public class SuperLongArray { private static int MASK = Integer.MAX_VALUE - 5; int[] left = new int [Integer.MAX_VALUE - 5]; int[] right = new int [Integer.MAX_VALUE - 5]; public int put(long address, int value) { if(address & MASK > 0) {//если значение указателя больше чем максимальное значение, то мы записывает его в левый массив int pointer = address - MASK; left[address] = value; } else { right[address] = value; } } public int get(long address) { if(address & MASK > 0) { int pointer = address - MASK; return left[address]; } else { return right[address]; } } }
Theoretically, you can continue indefinitely, but for the pointer you will have to use either a complex class and try BigDecimal