01.What is the LinkedHashSet?
- LinkedHashSet is a class
- LinkedHashSet is a Java.util package.
- LinkedHashSet maintain the insertion order.
- LinkedHashSet is allowed the "Null"value but one time only allowed.
- LinkedHashSet is not allowed the duplicate value.
- "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?
- Limited Access 2.Fixed Size in Static Implementations
Top comments (0)