Skip to content

Commit b981bfc

Browse files
authored
Update App.java
Added additional explanation on retainAll() and removeAll() methods.
1 parent 92f3540 commit b981bfc

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

55 - Sets/src/App.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,18 @@ public static void main(String[] args) {
6161

6262
////////////// Intersection ///////////////////
6363

64-
Set<String> intersection = new HashSet<String>(set1);
64+
Set<String> intersection = new HashSet<String>(set1);
6565

66-
intersection.retainAll(set2);
66+
intersection.retainAll(set2); // keeps similarities between set 1 and set 2
6767

6868
System.out.println(intersection);
6969

7070
////////////// Difference /////////////////////////
7171

72-
Set<String> difference = new HashSet<String>(set2);
72+
Set<String> difference = new HashSet<String>(set2);
7373

74-
difference.removeAll(set1);
74+
difference.removeAll(set1); // removes differences between set1 and set2, prints what is left of set2
7575
System.out.println(difference);
7676
}
7777

78-
}
78+
}

0 commit comments

Comments
 (0)