LinkedHashSet Class
It inherits the HashSet class and implements the Set interface.
- Java LinkedHashSet class contains unique elements only like HashSet.
- Java LinkedHashSet class provides all optional set operations and permits null elements.
- Java LinkedHashSet class is non-synchronized.
Java LinkedHashSet class maintains insertion order.Note: Keeping the insertion order in the LinkedHashset has some additional costs, both in terms of extra memory and extra CPU cycles. Therefore, if it is not required to maintain the insertion order, go for the lighter-weight HashMap or the HashSet instead.
Constructors
LinkedHashSet() : It is default constructor.
LinkedHashSet(int capacity) : It is used to initialize the capacity of the linked hash set 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.
Comments
Post a Comment