Disadvantages ArrayList Java Example
Disadvantages of ArrayList:
- Data entry: If new data is added or removed form ArrayList then its data needs to be shifted to update the list. If ArrayList has n numbers of data’s then an add or removes will take O(n) times.
- Memory: Data’s in the ArrayList is stored sequentially in the memory so for larger list will need significant contiguous blocks of memory.
- Capcity: ArrayList also has performance limitation, If you don’t specify initial capacity then by default it allocates it initial capacity which is 10. Every time when ArrayList hits its own capacity, data will be copy from old to new space with 50% more capacity.
- Boxing and Unboxing: ArrayList is not stronly typed as its loosly typed so boxing and unboxing takes place which hits its performance