The List class has two subclasses, ArrayList and LinkList. What’s the difference between ArrayList and LinkList

ArrayList

The bottom layer uses sequential representation, which is an array implementation, so List has the properties of an array

To add or delete

How does sequential representation add or remove?

Find a position to add or remove add: move all elements after this position back one bit, place the element to be added into the space created after other elements have been moved back delete: move all elements after this position forward one bit

so

Adding and deleting arrays is cumbersome, with O (1) complexity for adding or deleting the last bit

But adding and deleting in the middle of an array requires O (n-i) so adding and deleting in an array is approximately O (n)

Easy to locate

Because array positioning is based on subscripts, it is easy to access quickly and randomly

LinkList

Using a bidirectional List implementation List, with the characteristics of a List

Easy to add or delete

Linked lists are moved by address, so there is no need to move back when deleting or adding, so in addition and deletion, linked lists only need O (1) time complexity

Difficult to locate

Also because the list is moved by address, so only know who is in front or behind (two-way list), want to know the number of bits can only be found one by one, not like an array can be fast random access