Sets
Set in Java
// Java code for adding elements in Set
import java.util.HashSet;
import java.util.Set;
public class SetExample
{
public static void main(String[] args)
{
// Set demo using HashSet
Set<String> hash_Set = new HashSet<String>();
hash_Set.add("GyanSetu");
hash_Set.add("For");
hash_Set.add("GyanSetu");
hash_Set.add("Example");
hash_Set.add("Set");
System.out.print("Set output without the duplicates");
System.out.println(hash_Set);
}
} Basic Set operation :
Problems:
CC:
Last updated
Was this helpful?