之前说 ArrayList 是空的。然后我在 ArrayList 的索引 1,000,000 处添加一个对象。
ArrayList 会创建 1,000,001 个指针还是只创建一个指针?
将抛出 IndexOutOfBoundsException:
IndexOutOfBoundsException - 如果索引超出范围 (index < 0 || index > size())
http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html#add(int, E)
既然你问了,你甚至没有尝试过运行它。你会得到一个 IndexOutOfBounds 异常。