-
-
Save uncoded-ro/b28c71acf6124f3ef1c8e00dc3deded1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ro.virtualcampus.set; | |
import java.util.HashSet; | |
public class AppHashSet { | |
public static void main(String[] args) { | |
HashSet<String> multime1 = new HashSet<String>(); | |
multime1.add("Iulian"); | |
multime1.add("Corina"); | |
multime1.add("Ghita"); | |
multime1.add("Silviu"); | |
System.out.printf("multime nume %s %n", multime1); | |
for (String element : multime1) { | |
System.out.printf("%s, ", element); | |
} | |
System.out.printf("%n"); | |
HashSet<String> multime2 = new HashSet<String>(); | |
multime2.add("Maria"); | |
multime2.add("Ghita"); | |
multime2.add("Irina"); | |
multime1.addAll(multime2); | |
System.out.printf("multime nume %s %n", multime1); | |
multime1.removeAll(multime2); | |
System.out.printf("multime nume %s %n", multime1); | |
multime1.retainAll(multime2); | |
System.out.printf("multime nume %s %n", multime1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment