Advertisement
Guest User

IteratorListDemo Class

a guest
Mar 8th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.43 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package jasonandrewsca3;
  6.  
  7. import java.util.LinkedList;
  8. import java.util.List;
  9. import java.util.ListIterator;
  10.  
  11. /**
  12.  *
  13.  * @author Jason
  14.  */
  15. public class IteratorListDemo {
  16.     ListIterator i;
  17.  
  18.     public static void main(String arg[]) {
  19.        
  20.         //Node n1 = new Node("A");
  21.         Node n2 = new Node("B");
  22.         Node n3 = new Node("C");
  23.         Node n4 = new Node("D");
  24.         Node n5 = new Node("E");
  25.         Node n6 = new Node("F");
  26.        
  27.         IteratorList<String> list = new IteratorList<String>();
  28.         //LinkedList list = new LinkedList();
  29.         list.add(0,"A");
  30.         list.add(1,"B");
  31.         list.add(2,"C");
  32.         list.add(3,"D");
  33.         //list.remove(n1);
  34.         list.add(4,"E");
  35.         list.add(5,"F");
  36.         list.add(6,"G");
  37.         list.add(7,"H");
  38.         System.out.println(list);
  39.        
  40.         //list.insertBefore(n3, n5);
  41. //        list.hasNext();
  42.         //list.set(1,"J"); //will replace object "B" with an object "J".
  43. //        list.hasPrevious();
  44.         System.out.println("Is the list empty? Answer = " +list.isEmpty()+".");
  45.         //System.out.println(list);
  46.        
  47.         for(int i = 0; list.hasNext(); i++){
  48.             System.out.println();
  49.         }
  50.  
  51.         /*list = (IteratorList<String>)(ListIterator)myList;
  52.         while ( iter.hasNext()) {
  53.             System.out.println(iter.next());
  54.             }*/
  55.        
  56.        
  57.    
  58.         System.out.println("=================================");      
  59.         System.out.println("Does the list have a next object?");
  60.         //list.hasNext();
  61.         System.out.println("=================================");
  62.         //Node prevObject = mylist.hasPrevious();
  63.        // boolean nextObject = iter.hasNext();
  64.         //System.out.println("Is there an element" + prevObject);
  65.         //System.out.println("Elements of list = " + mylist);
  66.         //System.out.println("Does the list have a previous element?: "+list.hasPrevious());
  67.         //System.out.println(mylist.hasNext());
  68.         //System.out.println("The number of objects in the list is " + list.size() + ".");
  69.         System.out.println("Elements are in previous order. ");
  70.         //while (list.hasPrevious())
  71.         //{ System.out.println(list.previous()); }
  72.         //System.out.println(list);
  73.        
  74.        
  75.        
  76.     }
  77.    
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement