priority queue misbehaving
<pre><code>PriorityQueue&lt;Integer&gt; queue = new PriorityQueue&lt;Integer&gt;(4);
queue.add(8);
queue.add(5);
queue.add(23);
queue.add(6);
System.out.println(queue);
</code></pre>

<p>Friends,
The preceding code on Ubuntu 12.10 and Oracle Java 1.6 and Java 1.7, it is printing output as </p>

<pre><code>[5, 6, 23, 8]
</code></pre>

<p>I believe this is wrong. This should have instead printed as <code>[5, 6, 8, 23]</code>
Is this a defect? or my understanding of priority queue is wrong?</p>

<p>In addition to it, if I change the position of adding 23 to PriorityQueue before or after, this works as expected.</p>
