Hello in this Java programming tutorial, we are going to look at the sorted set collection. So it is basically built on top of a regular set and a preset preset is a way of organizing for regular sets. The list of items are in order and the sorted set. You don't have to create another subset to organize your existing set. It just organizes itself no matter what order you add the elements in. And to use it you just need to import Java dot util like so.
And now we're going to do is create a new preset and then we need to add you know the data to the set You know, 78 is still the same in that concrete duplicates in there. But we're over the phone, beef cleanly on in order. Now this is printed, overdue, sorted, sorted. Everything is in order, even though we didn't manually do that ourselves, which is really cool. So if you know you want to use a set, and you want it to be an order all the time, just use a sorted set. Okay, let me show you how to sort of go over each one.
You can use a iterator, iterator because that sorted iterator and we just do loyal dot has next. So while there's still another item that he can go through, we just do object element object equality because I got next like so. So this is just gonna get the next element will printer printer and just putting in here there we go. That's how we would get the element one by one if we wanted to the variety of other methods as well that you can use on a sorted set. I will provide a link to that with this video. So feel free to check that out.
That's it. Thanks for watching. If you have any question feel free to reach out and I I look forward to seeing you in the next awesome Java video.