Data Structure in Java-rule list

Source: Internet
Author: User
Java. util
CATEGORY list <E>
java.lang.Object  java.util.AbstractCollection<E>      java.util.AbstractList<E>          java.util.AbstractSequentialList<E>              java.util.LinkedList<E>
Type parameter:
E-Types of elements maintained in this collection
All Implemented interfaces:
Serializable,
Cloneable, iterable <E>,
Collection <E>, deque <E>,
List <E>, queue <E>

 

The listlist class implements the list interface. The list set implemented by the listlist class uses the linked list structure to save objects. The advantage of the linked list structure is that it is easy to insert and delete objects to the collection. If you often need to insert objects to the collection or delete objects from the collection, it is more efficient to use the list set implemented by the shortlist class. The disadvantage of the linked list structure is that the random access to objects is slow. If you often need to randomly access objects in the Set, the efficiency of using the list set implemented by the sorted list class is low.

 

Package COM. mwq; import Java. util. optional list; public class testcollection {public static void main (string [] ARGs) {system. out. println ("START:"); string a = "A", B = "B", c = "C", test = "test "; shortlist <string> List = new shortlist <string> (); list. add (a); // The index position is 0list. add (B); // The index position is 1list. add (c); // The index location is 2system. out. println (list. getfirst (); // obtain and output the list of objects starting with the list. addfirst (TEST); // Add an object system to the beginning of the list. ou T. println (list. getfirst (); // obtain and output the list of objects starting with the list. removefirst (); // removes the System Object starting with the list. out. println (list. getfirst (); // obtain and output the system object at the beginning of the list. out. println ("end! ") ;}} Execute the above Code and output the following information in the console: atesta

 

 

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.