SCJP 5
Mateus Henrique Brum
Sun Certified Java Programmer 6
Sun Certified Web Component Developer 5
Java Developer - SP - Brazil
SCJP 5.0(75%), SCWCD 5.0(88%)
SCJP 5
(yanked from javadocs)
The Iterator provided in method iterator() is not guaranteed to traverse the elements of the PriorityQueue in any particular order. If you need ordered traversal, consider using Arrays.sort(pq.toArray())
apigee, a better way to API!
SCJP 5.0(75%), SCWCD 5.0(88%)
Originally posted by pradeep singh:
Hi to all
I am not satisfied with Nitesh Kant solution because PriorityQueue orders its elements according to natural order i.e. 1 comes before 2 then 3... unless and untill we do not provide any ordering using Comparator.
And hence in this question we are not using Comparator .So ordering should be in natural order.
So i think(my personel view,may be i am wrong ) solution provide for above problem by Nitesh Kant is wrong.
apigee, a better way to API!
SCJP, SCWCD, SCBCD