What is TreeSet in Java? | Java TreeSet (Java Tutorial)

preview_player
Показать описание



******************** Java TreeSet Properties:
Implements the Set interface
Uses a tree for storage
Contains unique elements
Maintains ascending order

Java TreeSet constructors:
TreeSet() - It is the default constructor and creates an empty object and applies default sorting.
TreeSet(Collection c) - It creates an object using the elements of the collection c
TreeSet(Comparator comparator) - It creates an object and applying sorting based on the comparator implementation.
TreeSet(SortedSet sortedSet) - It creates a set using the elements from the sortedSet.

Java TreeSet Methods:
boolean add(Object targetObject) - It adds the targetObject in the set.
void clear() - It removes all the elements from the set.
Object clone() - It copies all the elements from the existing object and creates a new set object.
boolean isEmpty() - It returns if the set doesn't contain any elements.
boolean remove(Object o) - It removes the specified object from the set.
int size() - It returns the total elements count of the set.

#javatreeset #javacollections #programmingline #rakesh #rake

*******************************************************

Important Links:

*******************************************************

Subscribe my YouTube channels:

*******************************************************
Комментарии
Автор

Shouldn't 0 be somewhere else on this tree?

wojciechgizynski