Java ArrayBlockingQueue peek() MethodLast Updated : 17 Mar 2025 The peek() method of Java ArrayBlockingQueue class retrieves the head of this queue, but doesn't remove it. The method returns null if this queue is empty. Syntax:Parameters:NA Specified By:The peek() method of ArrayBlockingQueue class is specified by peek() method in interface Queue Return Value:The peek() method returns this queue's head and if this queue is empty,it returns null. Example 1Output:
Head of queue : Reema
Queue : [Reema, Rahul, Rita, Ramesh]
Example 2Output: Hinna got 97 marks. Vinni got 87 marks. Rima got 77 marks. Topper of the class is Hinna Example 3Output: Head of queue is : null Next TopicJava-arrayblockingqueue-poll-method |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India