• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

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

 
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
 
author & internet detective
Marshal
Posts: 38684
677
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!