Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Report : Java OCP 8 Programmer II Study Guide (Sybex)  RSS feed

 
Abdulaziz Akbary
Greenhorn
Posts: 5
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Abdulaziz Akbary
Greenhorn
Posts: 5
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We used "next" colloquially. I agree this could have been clearer.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!