ArrayList has the advantage of the fast query speed of the array and the disadvantage of the slow and delete speed

Source: Internet
Author: User

LinkedList interface (there is no difference between the use of code and ArrayList)

The ArrayList is an object array, so ArrayList has the advantage of fast query speed and the disadvantage of slow deletion.

At the bottom of the LinkedList is a two-way loop linked list. Each data node on this list is made up of three parts: the front pointer (pointing to the position of the previous node), the data, and the back pointer (pointing to the position of the following node). The last node's back pointer points to the front pointer of the first node, forming a loop.

The query efficiency of two-way circular linked list is low but the efficiency is high. Therefore, the LinkedList has the characteristics of low query efficiency but high efficiency and deletion.

There is no difference in usage between ArrayList and LinkedList, but there are differences in function.

LinkedList are often used in situations where there are more or less operations and few query operations: queues and stacks.

Queue: FIFO data structure.

Stack: A last-in, first-out data structure.

1  Packagetomtexts;2 3         classsuperclass{4             voidSuperPrint () {5System.out.println ("This is superclass!");6             }7         }8         classSubclassextendssuperclass{9             Ten             voidSuperPrint () { OneSystem.out.println ("This is subclass!");  A             } -         } -          Public classtomtexts_10{ the              Public Static voidMain (String args[]) { -Subclass Subobject =Newsubclass (); -Subobject.superprint ();//methods for subclass objects to call subclasses -Superclass Superobject =Newsuperclass (); +Superobject.superprint ();//Parent Class Object Calling method of parent class -             } +}

ArrayList has the advantage of the fast query speed of the array and the disadvantage of the slow and delete speed

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.