Esempio n. 1
0
 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);
   }
 }
Esempio n. 2
0
  public static void main(String[] args) {
    myList L = new myList();
    System.out.println(L);
    for (int i = 0; i < 5; i++) {
      L.add((i + 1) * 5);
    }
    System.out.println(L);
    L.add(3, 999);
    System.out.println(L);
    L.remove(3);
    System.out.println(L);

    stringList S = new stringList();
    System.out.println(S);
    for (int i = 0; i < 5; i++) {
      S.add(String.valueOf((i + 1) * 5));
    }
    System.out.println(S);
    S.add(3, "apples");
    System.out.println(S);
    S.remove(4);
    System.out.println(S);
    System.out.println(S.find("apples"));
    S.fremove("apples");
    System.out.println(S);
  }
Esempio n. 3
0
  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());
    }
  }