There is a advantages and disadvantage of using linked list as a container-
Insertion of elements in the list:
void insert():
Deletion of the elements from the list:
Disadvantages:
import java.util.*;
public class ListContainerTest {
public static void main(String args[])
{
// Creating object of the
// class linked list
LinkedList<String> lct
= new LinkedList<String>();
// insertion of new elements
lct.add("x");
lct.add("y");
lct.addLast("z");
lct.addFirst("s");
lct.add(2, "t");
System.out.println(lct);
lct.remove("s");
lct.remove(2);
lct.removeFirst();
lct.removeLast();
System.out.println(lct);
}
}
Comments
Leave a comment