summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/hjp5/examples/Listing1507.java
blob: 6004318dd916203036f8844ab85aabfc62ec99ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* Listing1507.java */

import java.util.*;

public class Listing1507
{
  public static void main(String[] args)
  {
    //Konstruieren des Sets
    List l = new ArrayList();
    l.add("Kiwi");
    l.add("Kirsche");
    l.add("Ananas");
    l.add("Zitrone");
    l.add("Grapefruit");
    l.add("Banane");
    //Unsortierte Ausgabe
    Iterator it = l.iterator();
    while (it.hasNext()) {
      System.out.println((String)it.next());
    }
    System.out.println("---");
    //Sortierte Ausgabe
    Collections.sort(l);
    it = l.iterator();
    while (it.hasNext()) {
      System.out.println((String)it.next());
    }
  }
}