Commit edcbcf08 authored by Qazi Zain's avatar Qazi Zain

Set Interfaces added

parent 20278587
package SetInterface.HashSet;
import java.util.*;
public class CoustomHashSet
{
HashSet<String> obj = new HashSet<>();
CoustomHashSet()
{
System.out.println("Object is Created!");
}
void displayHasetFunction()
{
//adding elements in HashSet.
obj.add("zain");
obj.add("Maaz");
obj.add("Hurriyah");
obj.add("Fatima");
obj.add("zain"); // would not add duplicate values.
System.out.println("Your Hashset is:"+obj);
// search in hashset
if( obj.contains("zain"))
{
System.out.println("Present in The List");
}
// for delete in HashSet
obj.remove("Hurriyah");
System.out.println("Your Hashset is:"+obj);
}
}
package SetInterface.HashSet;
public class Main {
public static void main(String[] args) {
CoustomHashSet obj = new CoustomHashSet();
obj.displayHasetFunction();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment