, 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.
I have always wanted to have a neighbor just like you - Fred Rogers. Tiny ad:
Thread Boost - a very different sort of advertising
This thread has been viewed 696 times.
All times above are in ranch (not your local) time.
The current ranch time is
Apr 23, 2018 15:33:56.