How to get the capacity of the ArrayList in Java?

后端 未结 9 878
灰色年华
灰色年华 2020-12-05 07:47

Its known that Java ArrayList is implemented using arrays and initializes with capacity of 10 and increases its size by 50% . How to get the current ArrayList capacity not t

9条回答
  •  渐次进展
    2020-12-05 08:10

    Default capacity of ArrayList is 10.once the max size is reached,new capacity will be:

    new capacity=(currentcapacity*3/2)+1.

提交回复
热议问题