What is the max capacity of an ArrayList?
问题 I know that the initial capacity of an ArrayList is 10. When this limit is exceeded, a new ArrayList is created with the capacity of (oldcapacity * 3 / 2) + 1 , and the elements are copied over. But what is the maximum capacity of an ArrayList? I was asked this question in an interview. The interviewer was not interested in the default initial capacity, but wanted to know the maximum capacity of an ArrayList. 回答1: Look in the source code: public ArrayList(int initialCapacity) { if