Find intersection of two sets (i.e. elements which appear in both the sets)
Sigiloso
Set s1 = new Hashset(); s1.add("ABC"); s1.add("DEF"); s1.add("GHI"); Set s2 = new Hashset(); s2.add("GHI"); s2.add("KLM"); s2.add("NOP"); Set union = new TreeSet(s1); union.addAll(s2); print(union) Set intersection = new TreeSet(s1); intersection.retainAll(s2); print(intersection);