LinkedList class for the Java collection framework

Source: Internet
Author: User

ArrayList uses an array as its data structure for preserving elements, while LinkedList uses the data structure of the linked list. Both ArrayList and LinkedList are linear table lists. But LinkedList does not have random access capabilities, and ArrayList owns.

For a list of linked lists, first (1) We use the ready-made LinkedList class in the API for some analysis, and then (2) We use our own Java code to implement the corresponding method in the linked list and its linkedlist.

(1) Analysis and use of ready-made API interfaces

Defined as follows, similar to ArrayList.

New Linkedlist<string> ();

As mentioned earlier, LinkedList does not have random access, which means that if you want to delete an element, you need to find it from scratch until you find the element at the specified location and then delete it. Let's just imagine that if the element to be deleted is in the back of the list, then this traversal of the list is actually time-consuming. Of course, if it is a doubly linked list, then it is convenient to manipulate the data elements near the head and tail of the linked list, but the operation of the elements in the middle of the list is a bit laborious.

LinkedList class for the Java collection framework

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.