Files
pharo-mooc/Java-Kompendium/kap6/Task3.java

30 lines
931 B
Java

import java.util.*;
public class Task3 {
public static void main(String[] args) {
var javaList = new HashSet<String>(3);
var pythonList = new HashSet<String>(3);
var commonList = new HashSet<String>();
var differenceSet = new HashSet<String>();
javaList.add("Maximilian Mayer");
javaList.add("Emil Faber");
javaList.add("Anna Müller");
pythonList.add("Anna Müller");
pythonList.add("Sebastian Waller");
pythonList.add("Oliver Stilz");
commonList.addAll(javaList);
commonList.addAll(pythonList);
differenceSet.addAll(javaList);
differenceSet.retainAll(pythonList);
System.out.println("Java-Kurs: " + javaList);
System.out.println("Python-Kurs: " + pythonList);
System.out.println("Alle Teilnehmer: " + commonList);
System.out.println("Beide Kurse: " + differenceSet);
}
}