• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

poll() problem

 
gaurav gupta sitm
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic