Differences between ArrayList and javaslist and code parsing in use scenarios,
This article focuses on the differences between ArrayList and javaslist in Java programming and related content in use scenarios. The specific introduction is as follows.
1. ArrayList is implemented based on arrays. Its constructor is:
Private transient Object [] elementData; private int size;
During ArryList initialization, the default elementData array size is 10;
Each time you add (), call ensureCapacity () to ensure that the array will not overflow. If it is full, it will be expanded to 1.5 times of the array length + 1, and then use array. copy the original array to the new array;
The ArrayList thread is not secure. The Vector method is synchronous and the thread is secure;
2. The explain list is implemented based on double-stranded tables:
Object element; Entry next, previous;
During initialization, there is a header Entry with a value of null;
The advantage of using header is that there is a front entry and a rear entry in any entry (including the first and last one, therefore, there is no special place for the insert operation at the beginning or end of the listing list object;
Use Cases:
(1) If the application accesses or deletes a large number of elements at each index location, the ArrayList object is far better than the partial list object;
(2) If the application mainly loops the list and inserts or deletes the list during the loop, the sorted list object is far better than the ArrayList object.
Summary
The above is all about the differences between ArrayList and javaslist and the use case code parsing. I hope it will be helpful to you. If you are interested, you can continue to refer to other related topics on this site. If you have any shortcomings, please leave a message. Thank you for your support!