Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • 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
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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
Posts: 39129
723
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.
 
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!