Skip to content

Latest commit

 

History

History
51 lines (36 loc) · 1.02 KB

File metadata and controls

51 lines (36 loc) · 1.02 KB

HashSet

  1. Create a HashSet and add some elements to it. Then, print the elements of the HashSet.
  2. Write a program to check if a particular element exists in a HashSet.
  3. Create a HashMap to store the mappings of country names to their capitals.
  4. Write a program to find the common elements between two ArrayLists.
  5. Create a TreeMap to store the mappings of words to their frequencies in a given text.
  6. Write a program to check if a HashSet is a subset of another HashSet.

Code Snippets

Problem 1

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);
    }
}

#Problem 2

#Problem 3

#Problem 4

#Problem 5

#Problem 6