예제 #1
0
파일: Driver.java 프로젝트: trunkatedpig/hw
  public static void main(String[] args) throws FileNotFoundException {
    String s;

    ArrayList<String> AL = new ArrayList<String>();
    AL.add("one");
    AL.add("two");
    AL.add("three");
    AL.add("four");
    AL.add("five");
    AL.add("six");
    System.out.println("ArrayList (iterator) " + AL);
    Iterator<String> it = AL.iterator();
    while (it.hasNext()) {
      s = it.next();
      System.out.println("AL: " + s);
    }
    System.out.println();

    myList ml = new myList();
    ml.add(20);
    ml.add(50);
    ml.add(12);
    ml.add(13);
    ml.add(53);
    ml.add(33);
    ml.add(23);

    System.out.println(ml);
    Iterator<Integer> mlit = ml.iterator();
    while (mlit.hasNext()) {
      System.out.println(mlit.next());
    }
  }
예제 #2
0
파일: Driver.java 프로젝트: trunkatedpig/hw
 public static void main(String[] args) throws FileNotFoundException {
   /*
   String s;
   ArrayList<String> al = new ArrayList<String>();
   al.add("one");
   al.add("two");
   al.add("three");
   al.add("four");
   al.add("five");
   al.add("six");
   System.out.println("ArrayList: (iterator): "+al);
   Iterator<String> it = al.iterator();
   while (it.hasNext()){
       s=it.next();
       System.out.println("ArrayList (iterator): "+s);
   }
   System.out.println();
   */
   String s1 = "";
   myList ml = new myList();
   ml.add(20);
   ml.add(50);
   ml.add(15);
   ml.add(8);
   System.out.println(ml);
   Iterator<Integer> mlit = ml.iterator();
   while (mlit.hasNext()) {
     s1 = mlit.next() + "";
     System.out.println("myList (iterator): " + s1);
   }
 }