LinkedHashSet in Java | Example Program

LinkedHashSet in Java is a concrete class that implements set interface and extends HashSet class with a doubly linked list implementation. It internally uses a linked list to store the elements in the set. It was added in Java 1.4 version. Java LinkedHashSet class is the same as HashSet class, … Read more

TreeSet in Java | Methods, Example

TreeSet hierarchy in Java

A TreeSet in Java is another important implementation of the Set interface that is similar to the HashSet class, with one added improvement. It sorts elements in the ascending order while HashSet does not maintain any order. Java TreeSet implements SortedSet interface. It is a collection for storing a set … Read more

How to Iterate Set in Java

In this tutorial, we will learn how to iterate Set in Java. Set interface does not provide any get() method like the List interface to retrieve elements. Therefore, the only way to take out elements from the set can be by using Iterator() method but this method does not return … Read more

Java HashSet | Example Program

The collections framework provides two general-purpose set implementations in Java: HashSet and TreeSet. In this tutorial, we will learn HashSet in Java with example programs in an easy way. HashSet class was introduced in Java 1.2 version and it is present in java.util.HashSet package. It internally uses HashMap to store … Read more

How to Iterate LinkedList in Java

In the last tutorial, we have discussed Java LinkedList and its various methods. In this tutorial, we will learn how to iterate LinkedList in Java. Before going on this topic, I will recommend that you first learn the basics of LinkedList in Java then come on this topic. There are … Read more