DEV Community

velvizhi Muthu
velvizhi Muthu

Posted on

Module 5-LinkedHashSet and Queue

01.What is the LinkedHashSet?

  1. LinkedHashSet is a class
  2. LinkedHashSet is a Java.util package.
  3. LinkedHashSet maintain the insertion order.
  4. LinkedHashSet is allowed the "Null"value but one time only allowed.
  5. LinkedHashSet is not allowed the duplicate value.
  6. "removeFirst" is removed the first index and no need to mention the index value. 7."removeLast" is removed the last index and no need to mention the index value.

02.Advantage of LinkedHashSet?
1.Maintains Insertion Order
2.No Duplicate Elements

03.DisAdvantage of LinkedHashSet?
1.More Memory Overhead
2.No Sorted Order
3.Not Thread-Safe

Methods in LinkedHashSet:

add(E e) – add element
remove(Object o) – remove element
contains(Object o) – check if present
size() – number of elements
clear() – remove all elements
isEmpty() – check if empty

04.What is queue?
1.Queue is an interface in java.util package.
2.It is used to store elements in a FIFO (First-In-First-Out) order,
like people standing in a line.
3.Supports insertion at the tail and removal from the head.
4.Does not allow random access like a list.

05.Advantage of Queue?
1.FIFO Order (First-In-First-Out)
2.Efficient Insertions and Deletions

06.Disadvantage of Queue?

  1. Limited Access 2.Fixed Size in Static Implementations

Top comments (0)