Java LinkedHashSet class

Java LinkedHashSet class is a Hash table and Linked list implementation of the set interface. It inherits HashSet class and implements Set interface.

  • Contains unique elements only like HashSet.
  • Provides all optional set operations, and permits null elements.
  • Maintains insertion order.
  • Hierarchy of LinkedHashSet class

    The LinkedHashSet class extends HashSet class which implements Set interface. The Set interface inherits Collection and Iterable interfaces in hierarchical order.

    LinkedHashSet class declaration

    public class LinkedHashSet extends HashSet implements Set, Cloneable, Serializable

    Constructors of Java LinkedHashSet class

    HashSet() It is used to construct a default HashSet.

    HashSet(Collection c) It is used to initialize the hash set by using the elements of the collection c.

    LinkedHashSet(int capacity) It is used initialize the capacity of the linkedhashset to the given integer value capacity.

    LinkedHashSet(int capacity, float fillRatio) It is used to initialize both the capacity and the fill ratio (also called load capacity) of the hash set from its argument.

    EXAMPLE

    Flash Soon



    Advertisement

    © Sapster 2017