wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes poll() problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "poll() problem" Watch "poll() problem" New topic
Author

poll() problem

gaurav gupta sitm
Greenhorn

Joined: Jan 12, 2011
Posts: 22


why above program shows bye 2 followed by ConcurrentModificationException
but below program compile fine

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

poll method Retrieves and removes the head of this queue . so when you remove an element from collection at the time of looping you get ConcurrentModificationException. to remove an element while looping use Iterator instead.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: poll() problem
 
Similar Threads
PriorityQueue Question
doubt in John Meyer's mock exam - ConcurrentModificationException!
Modifying PriorityQueue keys while in queue
another question from scjptest.com
PriorityQueue order?