Let’s learn TreeSet tailSet(E fromElement, boolean inclusive) method in java. TreeSet tailSet(E fromElement, boolean inclusive) method in java tailSet(E fromElement, boolean inclusive) method of TreeSet class returns a view of the portion of this set whose elements are greater than (or equal to, if inclusive is true) fromElement. Syntax: public NavigableSet<E> tailSet(E fromElement, boolean inclusive)…

Read More TreeSet tailSet(E fromElement, boolean inclusive) method in java

Let’s learn TreeSet tailSet(E fromElement) method in java. TreeSet tailSet(E fromElement) method in java tailSet(E fromElement) method of TreeSet class returns a view of the portion of this set whose elements are greater than or equal to fromElement. Syntax: public SortedSet<E> tailSet(E fromElement) Parameters: fromElement low endpoint (inclusive) of the returned set. Throws: ClassCastException –…

Read More TreeSet tailSet(E fromElement) method in java

Let’s learn TreeSet subSet(E fromElement, E toElement) method in java. TreeSet subSet(E fromElement, E toElement) method in java subSet(E fromElement, E toElement) method of TreeSet class returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive. Syntax: public SortedSet<E> subSet(E fromElement, E toElement) Parameters: fromElement low endpoint…

Read More TreeSet subSet(E fromElement, E toElement) method in java

Let’s learn TreeSet subSet() method in java. TreeSet subSet() method in java subSet() method of TreeSet class returns a view of the portion of this set whose elements range from fromElement to toElement. Syntax: public NavigableSet<E> subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) Parameters: fromElement low endpoint of the returned set. fromInclusive true if…

Read More TreeSet subSet() method in java

Let’s learn TreeSet size() method in java. TreeSet size() method in java size() method of TreeSet class returns the number of elements in this set (its cardinality). Syntax: public int size() Now let’s see example on TreeSet size() method. import java.util.TreeSet; public class TreeSetSizeMethodExample { public static void main(String[] args) { TreeSet<String> ts = new…

Read More TreeSet size() method in java

Let’s learn TreeSet last() method in java. TreeSet last() method in java last() method of TreeSet class returns the last (highest) element currently in this set. Syntax: public E last() Throws: NoSuchElementException – if this set is empty. Now let’s see example on TreeSet last() method. import java.util.TreeSet; public class TreeSetLastMethodExample { public static void…

Read More TreeSet last() method in java

Let’s learn TreeSet iterator() method in java. TreeSet iterator() method in java iterator() method of TreeSet class returns an iterator over the elements in this set in ascending order. Syntax: public Iterator<E> iterator() Now let’s see example on TreeSet iterator() method. import java.util.Iterator; import java.util.TreeSet; public class TreeSetIteratorMethodExample { public static void main(String[] args) {…

Read More TreeSet iterator() method in java

Let’s learn TreeSet isEmpty() method in java. TreeSet isEmpty() method in java isEmpty() method of TreeSet class returns true if this set contains no elements. Syntax: public boolean isEmpty() Parameters: isEmpty() method do not take any parameters. Now let’s see example on TreeSet isEmpty() method. import java.util.TreeSet; public class TreeSetIsEmptyMethodExample { public static void main(String[]…

Read More TreeSet isEmpty() method in java