What is the difference between navigableset, sortedset and TreeSet in Java?

TreeSet places elements in a natural sort or a comparator provided by

Sortedset also maintains elements in natural order

But what's the difference between them and navigableset?

Where is navigablesets useful? Some examples showing its use will be good for beginners

Solution

Sortedset is an interface (which defines functions), and TreeSet is an implementation Navigableset is also the interface subtype of sortedset

You cannot write only sortedset < integer > example = new sortedset < integer > ();

However, you can write sortedset < integer > example = new TreeSet < integer > ();

As the name suggests, navigablesets are more useful for browsing collections

http://mrbool.com/overview-on-navigableset-subtype-of-java-collections/25417 Provides a good tutorial on navigablesets. When using a method that is not available in sortedset, you can use some methods

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>