TreeSet: Creation and Insertion
Let's look at TreeSet creation and insertion.
We'll cover the following
Java TreeSet class implements the Set interface that uses a tree for storage. It inherits the AbstractSet class and implements the NavigableSet interface.
Some of the features of TreeSet are:
- TreeSet does not allow duplicate elements.
- TreeSet class doesn’t allow null elements.
- Since elements are stored in a tree, the access and retrieval times are quite fast in a TreeSet.
- The elements are stored in ascending order in a TreeSet.
Get hands-on with 1400+ tech skills courses.