Übung 15. KW

export PATH=/usr/java/jdk1.6.0/bin:$PATH
eclipse &

Window $ \to$ Preferences $ \to$ Java $ \to$ Compiler $ \to$ compiler compliance level $ \to$ 6.0

Window $ \to$ Preferences $ \to$ Java $ \to$ Compiler $ \to$ Errors/Warning $ \to$ JDK 6.0 Options $ \to$ Unchecked type ops $ \to$ Error (anderes $ \to$ Warning)

Beispiele aus Vorlesung ausprobieren:

implementiere polymorphe Funktion

static <E> LinkedList<E> shuffle (List<E> in) { ... }
soll aus [1, 2, 3, 4, 5, 6, 7, 8] die Liste [7, 5, 3, 1, 2, 4, 6, 8] erzeugen, usw.

Benutze zum Zugriff auf in nur for (E x : in) { ... } (d. h. kein in.get())

Benutze zum Erzeugen der Ausgabeliste

LinkedList<E> out = new LinkedList<E> ();
die Methoden addFirst, addLast sowie eine boolesche Variable zum Umschalten zwischen beiden.

Rufen Sie shuffle mehrfach auf, z. B.

public static void main(String[] argv) {
   List<String> in = Arrays.asList (argv);
   // List<Integer> = make (8);
   System.out.println (in);
   in = shuffle (in);
   System.out.println (in);
}
(Fügen Sie eine Schleife ein.)



Johannes Waldmann 2007-06-21