, Ranch Hand
Should not the following code give ConcurrentModificationException as we are
using the for-each loop and doing poll() on the PriorityQueue
The output is =============== 2.
Could not understand why this is happening ??
I don't see anything in the API documentation for the iterator() method of PriorityQueue which suggests it might do that.
Agreed. Modifying a collection while iterating is not a good idea because you can get a concurrent modification exception. It doesn't mean that you always will.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards
This thread has been viewed 669 times.
All times above are in ranch (not your local) time.
The current ranch time is
Jan 19, 2018 04:44:25.