Java Utility Library

Java.util.LinkedHashSet Class



Java LinkedHashSet Class

Java.util package provides a LinkedHashSet class which is a Hash table and linked list implementation of the Set interface, with predictable iteration order. This implementation differs from HashSet in that it maintains a doubly-linked list running through all of its entries. This class provides all of the optional Set operations, and permits null elements.

Class declaration

The declaration of java.util.LinkedHashSet class is:

public class LinkedHashSet<E>
  extends HashSet<E>
    implements Set<E>, Cloneable, Serializable

Here, E is the type of element maintained by the container.

Class Constructors

S.NConstructors & Description
1. LinkedHashSet()
Constructs a new, empty linked hash set with the default initial capacity (16) and load factor (0.75).
2. LinkedHashSet(Collection<? extends E> c)
Constructs a new linked hash set with the same elements as the specified collection.
3. LinkedHashSet(int initialCapacity)
Constructs a new, empty linked hash set with the specified initial capacity and the default load factor (0.75).
4. LinkedHashSet(int initialCapacity, float loadFactor)
Constructs a new, empty linked hash set with the specified initial capacity and load factor.

java.util.LinkedHashSet Methods

The java.util.LinkedHashSet class has a number of methods which are listed below:

Member Methods

S.NMethods & Description
1. Spliterator<E> spliterator()
Creates a late-binding and fail-fast Spliterator over the elements in this set.

Methods inherited

This class inherits the methods of following class:

  • java.lang.Object
  • java.util.AbstractCollection<E>
  • java.util.AbstractSet<E>
  • java.util.HashSet<E>