The set interface defines a set. It also extends collections. It declares the behavior of a collection that does not allow duplicate elements. In this interface add () method returns false if an attempt is made to duplicate elements to a set. A set interface does not define any additional methods of its own.
The sorted set interface:
- Sorted set interface extends set interface.
- It declares the behavior of a set sorted in ascending order.
- In addition to those methods defined by set, the sorted set interface declares the following methods.
Returns the invoking sorted sets comparator, if the natural ordering is used for the set, null is returned.
In this returns the first element in the invoking sorted set.
Sortedset headset (object end):
Returns a sorted set containing those elements less than the end that is contained in the invoking sorted set. Elements in the returned sorted set are also referenced by the invoking sorted set.
Object last ():
In this returns the last element in the invoking sorted set.
Sortedset subset (object start, object end):
In this returns a sorted set that includes those elements between start and end -1. Elements in the returned collection are also referenced by the invoking object.
Sortedset tailset (object start):
Returns a sorted set that contains those elements greater than or equal to start that are contained in the sorted set. Elements in the returned set are also referenced by the invoking object.
int size() :
Returns the number of elements in this collection