The Collection Framework provides two general-purpose implementations of
the set interface;
They are available in the java.util package.
TreeSet stores objects in a sorted manner. It stores its elements in a tree and they are automatically arranged in a sorted order.
It lets you access the elements in your collection by key, or sequentially by key.
The TreeSet implementations are useful when the developers need to extract elements from a collection in a sorted manner.
TreeSet is not synchronized i.e. if more than one thread wants to access it at the same time then it must be synchronized externally.
Read more at:
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial
Discuss: Java TreeSet
Post your Comment