Menu
Question Index
...

Write a program to remove the elements of first input which elements are matched with second input or not?.
By using one of the Set interface methods.

Input (HashSet, HashSet) Output (Boolean)
[1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6] true
[Cricket, Chess, Hockey, Foot Ball], [Foot Ball, Chess, Race] true
['M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T'], ['A', 'B', 'C', 'D', 'E'] fasle
[Apple, Rose, Pink, Banana], null null


import java.util.*;
class RemoveElements
{
    public static void main(String s[])
    {
        HashSet input1 = new HashSet();
        input1.add(1);
        input1.add(2);
        input1.add(3);
        input1.add(4);
        input1.add(5);
        HashSet input2 = new HashSet();
        input2.add(4);
        input2.add(6);
        input2.add(3);
        System.out.println("Are removed elements: " + areRemoved(input1, input2));

    }


    public static Boolean areRemoved(HashSet input1, HashSet input2) {
    }

}

Doubts

Problems

Topic: HashSet Class In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App