SortedMap

1 minutes
Share the link to this page
Copied
  Completed
A Map that further provides a total ordering on its keys. The map is ordered according to the natural ordering of its keys, or by a Comparator typically provided at sorted map creation time. This order is reflected when iterating over the sorted map's collection views (returned by the entrySet, keySet and values methods). Several additional operations are provided to take advantage of the ordering

Transcript

Hello, in this Java programming video, we are going to look at the sorted map collection. So the sorting map is very similar to a regular, you know, map, but the actual values are sorted. So if we run this, and you'll see that the values aren't in the order that we input them, but if you if we want to ensure that they're, you know, not not necessarily in the order that we put them but they're in ascending order motherfucking ascending by one key or when it's by key, so we should be in you know, this in order to do it, it is really simple. Instead of using a hash map you the tree map. So if I change this to three map now, mode so and run it, they go hit Run, and they're in order. That's literally all you have to do.

So if you haven't watched the soul I mean the map entry and the map tutorials, watch them, then come back to this one and then just have a look. That's all you're doing changes to the map. So let me just you know, have a look. So for portlets I key zero here. He or put 70 and I'll put 60. So this should hopefully reorder them if they go is reorder them 0123456 and seven.

So that is it for this Java tutorial. If you have any questions, feel free to reach out and I look forward to seeing you in the next awesome Java video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.