[Logo]
Forums Register Login
Report : Java OCP 8 Programmer II Study Guide (Sybex)

Chapter: 3, Page: 136, Table 3.5

The peek() method description says "Returns next element or returns null if empty queue"
As I realized, the peek () method will Retrieves, the head of the queue, or returns null if this queue is empty. please make me correct, if I understood wrong.

Regards,
Abdulaziz Akbary

Chapter: 3, Page: 136, Table 3.5

The element() method description says "Returns next element or returns throws an exception if empty"
The peek() method description says "Returns next element or returns null if empty queue"

As I realized, the peek () method will Retrieves, the head of the queue, or returns null if the queue is empty.
The element() method Retrieves, the head of the queue.This method differs from peek because it throws an exception if the queue is empty.

The pop() and poll() will remove the head of the queue.

please make me correct, if I understood wrong.

Regards,
Abdulaziz Akbary
We used "next" colloquially. I agree this could have been clearer.

This thread has been viewed 280 times.

All times above are in ranch (not your local) time.
The current ranch time is
Sep 21, 2018 03:28:57.