Retrieving n values from treemaps in java
<p>I'm using treemaps in my java program. The output of the program is a sorted map as follows</p>

<pre><code>[cat=1, dog=1, pin=3, ball=4, mice=4..... and so on]
</code></pre>

<p>I want to display only first 3 values of the map instead of displaying the whole map.
I want my output as follows</p>

<pre><code>cat=1
dog=1
pin=3
</code></pre>

<p>How can i do this? </p>
