TreeSet: Fetching and Removal
Let's discuss fetching and removal operations in TreeSet.
We'll cover the following...
Fetching an element from a TreeSet
The following methods can be used to fetch elements from a TreeSet.
Fetching the first element
We can fetch the first element in the TreeSet using the first()
method. If the TreeSet is empty, then NoSuchElementException
is thrown.
Fetching the last element
We can fetch the last element in the TreeSet ...