![]() offer(E e): It inserts the element into the queue if it is possible to do so. ![]() It will return null if the queue is empty. poll()- This method returns and removes the head of the queue.It will throw NoSuchElementException when queue is empty. remove()- It will remove and return the head of the queue.It throws NoSuchElementException when queue is empty. It will return Null if the queue is empty. peek()- It is used to view the head of queue without deleting it.add()- It is used to add elements at the tail of queue.Some important methods of Queue interface Some Queue implementation classes are LinkedList, ArrayBlockingQueue, PriorityQueue, LinkedBlockingQueue, DelayQueue, PriorityBlockingQueue etc. Java Queue interface extends Collection interface. BlockingQueue are mostly used to perform the Producer/Consumer based problems.BlockingQueue can be used in multithreaded environment because they are thread-safe.BlockingQueue can not store null elements.Deques will support element insertion and deletion at both ends. All Queues except the Deques will support insertion and deletion at the tail and head of the queue respectively.The Queues available in package are the Bounded Queues.The Queues available in java.util package are Unbounded Queues.Important Queue implementations are LinkedList, PriorityQueue and ArrayBlockingQueue.It supports all methods of Collection interface like insertion, deletion etc. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |