1 , what is ArrayList
ArrayList is the legendary dynamic array, which, in MSDN parlance, is a complex version of array that provides some of the following benefits:
- Dynamic increase and decrease of elements
- Implements the ICollection and IList interfaces
- Flexibility to set the size of the array
2. What is Linklist
A linked list (Linked list) is a common basic data structure, a linear table, but does not store data in a linear order, but rather as a pointer to the next node (Pointer) in each node. Since they do not have to be stored sequentially, the list can achieve an O (1) complexity at the time of insertion, much faster than another linear table-order table, but the time to find a node or to access a particular number of nodes requires O (n), while the corresponding time complexity of the sequential table is O (logn) and O (1)
3, ArrayList and LinkedList of the general difference:
- ArrayList is the realization of the data structure based on dynamic array, LinkedList data structure based on the linked list.
- For random access get and set,arraylist are better than LinkedList, because linkedlist to move the pointer.
- Add and Remove,linedlist are the dominant for new and deleted operations because ArrayList is moving the data. However, this is to see the actual situation, If only a single data inserted or deleted, ArrayList speed is better than LinkedList. But if bulk random insert deletes data, LinkedList speed is much better than ArrayList. Because ArrayList each insertion of data, you move the insertion point and all subsequent data.
"Java" ArrayList and Linklist