Javatpoint Logo
Javatpoint Logo

Java LinkedTransferQueue peek() Method

The peek() method of Java LinkedTransferQueue class retrieves the head of this queue, but doesn't remove it. The method returns null if this queue is empty.




Specified By:

The peek() method of LinkedTransferQueue class is specified by peek() method in interface Queue<E>.

Return value:

The peek() method returns this queue's head and if this queue is empty, it returns null.

Example 1

Test it Now


Head of queue : Jack
        Queue : [Jack, Harry, Peter, Krish]

Example 2

Test it Now


Harry got 97 marks.
John got 87 marks.
Peter got 77 marks.

Topper of the class is Harry

Example 3

Test it Now


Head of queue is : null

Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials

B.Tech / MCA