Skip to content

Tag Archives: java-hashset

In HashSet, duplicates are not allowed. If we are trying to insert duplicates then we won’t get any compile-time or runtime error and the add()… Read More
HashSet is used to store distinct values in Java. HashSet stores the elements in random order, so there is no guarantee of the elements’ order.… Read More
The HashSet class implements the Set interface, backed by a hash table which is actually a HashMap instance. There is no guarantee made for the… Read More
ArrayList class is a resizable array, present in java.util package. The difference between an array and an ArrayList in Java, is that the size of… Read More
Given a string str, the task is to print all the permutations of str. A permutation is an arrangement of all or part of a… Read More
Given an array arr[] of N elements, the task is to check whether the array have all same (identical) elements or not without using the… Read More
Given a person who is at position current_pos and a binary string path which is the moves the person took, if path[i] = ‘0’ then… Read More
Given an array arr[], the task is to print the count of unique pairs (arr[i], arr[j]) such that i < j. Examples:  Input: arr[] =… Read More
Hashset: Hashset in Java is generally used for operations like search, insert and delete. It takes constant time for these operations on average. HashSet is… Read More
In this article, we will learn, the difference between HashSet vs LinkedHashSet and TreeSet And similarities between LinkedHashSet and TreeSet. HashSet, LinkedHashSet, and TreeSet all… Read More
The removeAll() method of java.util.HashSet class is used to remove from this set all of its elements that are contained in the specified collection.Syntax:  public… Read More
The toString() method of Java HashSet is used to return a string representation of the elements of the Collection. The String representation comprises a set… Read More
The containsAll() method of Java HashSet is used to check whether two sets contain the same elements or not. It takes one set as a… Read More
The equals() method of java.util.HashSet class is used verify the equality of an Object with a HashSet and compare them. The list returns true only… Read More
The toArray(T[]) method method of HashSet class in Java is used to form an array of the same elements as that of the HashSet. It… Read More

Start Your Coding Journey Now!