The basic method of LinkedList collection in Java programming language demo
Import Java.util.iterator;import Java.util.linkedlist;public class Linkedlistdemos {public static void main (string[] args) {//Create a new container linkedlist link = new LinkedList (); Link.addfirst ("ABC1"); Link.addfirst ("ABC2"); Link.addfirst (" ABC3 "); Link.addfirst (" ABC4 "); Link.addfirst (" Abc5 "); Iterator it = Link.iterator (); while (It.hasnext ()) { System.out.println (It.next ());} System.out.println ("Gets the first element in the collection:" +link.getfirst ()); System.out.println ("Gets the last element in the collection:" +link.getlast ()); System.out.println ("Gets the first element in the collection and deletes the element:" +link.removefirst ()); System.out.println ("Gets the last element in the collection and deletes the element:" +link.removelast ());}}
To run the program:
The basic method of LinkedList collection in Java programming language demo