uebung09 small adjustments

This commit is contained in:
2025-06-12 12:10:00 +02:00
parent 57aae3eda6
commit b2eb22a6cc
7 changed files with 300 additions and 119 deletions

View File

@@ -0,0 +1,29 @@
package collection;
public class SetDemo {
public static void main(String[] args) {
final Set<String> set1 = SetFactory.create();
System.out.println("set1 = " + set1);
final Set<String> set2 = set1.add("foo");
System.out.println("set2 = " + set2);
final Set<String> set3 = set2.add("foo");
System.out.println("set3 = " + set3);
final Set<String> set4 = set3.add("bar");
System.out.println("set4 = " + set4);
final Set<String> set5 = SetFactory.create("foo", "baz", "foo");
System.out.println("set5 = " + set5);
final Set<String> set6 = set4.union(set5);
System.out.println("set6 = " + set6);
final Set<String> set7 = set4.intersection(set5);
System.out.println("set7 = " + set7);
final Set<String> set8 = set5.intersection(set4);
System.out.println("set8 = " + set8);
}
}