Linked Lists

Cards (6)

  • Collection
    container that stores objects
  • list
    ordered collection of elements; list size grows and shrinks as elements are removed
  • LinkedList
    stores elements in a doubly linked list
  • LinkedList object creation
    import java.util.LinkedList;
    LinkedList<String>toDoList=newLinkedList<String>();
    LinkedList<Integer>parkingSpacesList=newLinkedList<Integer>();
  • LinkedList iterator
    import java.util.Iterator;
    Iterator<String>iterator=toDoList.iterator();

    while(iterator.hasNext())
    {
    System.out.println(iterator.next());
    }
  • enhanced for loop option to traverse all elements in the collection
    for(String element: toDoList) // For each String element in toDoList{System.out.println(element);}