Source of StringLLWithIteratorDemo.java


  1: //StringLLWithIteratorDemo.java
  2: 
  3: public class StringLLWithIteratorDemo
  4: {
  5:     public static void main(String[] args)
  6:     {
  7:         StringLLWithIterator list = new StringLLWithIterator();
  8:         list.addANodeToStart("Spring");
  9:         list.addANodeToStart("Winter");
 10:         list.addANodeToStart("Fall");
 11:         list.addANodeToStart("Summer");
 12:         System.out.println("List has " + list.length() + " entries.");
 13:         list.showList();
 14:         System.out.println();
 15: 
 16:         System.out.println("Start of list:");
 17:         list.resetIteration();
 18:         while (list.moreToIterate())
 19:         {
 20:             System.out.println(list.getDataAtCurrent() + " ");
 21:             list.goToNext();
 22:         }
 23:         System.out.println("End of list.");
 24:         System.out.println();
 25: 
 26:         list.resetIteration();
 27:         list.setDataAtCurrent("New first item");
 28:         list.insertNodeAfterCurrent("New second item");
 29:         list.goToNext();
 30:         list.goToNext();
 31:         System.out.println("List after changing first item and ");
 32:         System.out.println("inserting new second item:");
 33:         list.showList();
 34:         System.out.println();
 35: 
 36:         list.deleteCurrentNode();
 37:         System.out.println("List after deleting third item:");
 38:         list.showList();
 39:     }
 40: }