"Java" ArrayList and Linklist

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.