• Post Reply Bookmark Topic Watch Topic
  • New Topic

[SCJP] PriorityQueue order

 
Paulo Gervásio
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have one doubt about how PriorityQueue prints yours items when calls toString() ...
Let me explain better, I have this code:


and it prints [1, 3, 2]...

Look what the JavaDoc says about Iterator:
Returns an iterator over the elements in this queue. The iterator does not return the elements in any particular order.


Anyone knows what is this order or in what its based?

Thanks.

Ps.: This code I found in http://scjptest.com
 
Ankit Garg
Sheriff
Posts: 9597
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question has been asked many times before like here, here and here...
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!