Add Java-Kompendium book
This commit is contained in:
29
Java-Kompendium/kap6/Task3.java
Normal file
29
Java-Kompendium/kap6/Task3.java
Normal file
@@ -0,0 +1,29 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user