- Create a HashSet and add some elements to it. Then, print the elements of the HashSet.
- Write a program to check if a particular element exists in a HashSet.
- Create a HashMap to store the mappings of country names to their capitals.
- Write a program to find the common elements between two ArrayLists.
- Create a TreeMap to store the mappings of words to their frequencies in a given text.
- Write a program to check if a HashSet is a subset of another HashSet.
import java.util.HashSet;
public class Main {
public static void main(String[] args) {
HashSet<String> set = new HashSet<>();
set.add("apple");
set.add("banana");
set.add("orange");
System.out.println("HashSet elements: " + set);
}
}