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