Let’s learn TreeSet clone() method in java. TreeSet clone() method in java clone() method of TreeSet class returns a shallow copy of this TreeSet instance. Syntax: public Object clone() Now let’s see example on TreeSet clone() method. import java.util.TreeSet; public class TreeSetCloneMethodExample { public static void main(String[] args) { TreeSet<String> ts = new TreeSet<String>(); ts.add(“green”);…

Read More TreeSet clone() method in java

Let’s learn TreeSet descendingSet() method in java. TreeSet descendingSet() method in java descendingSet() method of TreeSet class returns a reverse order view of the elements contained in this set. The descending set is backed by this set, so changes to the set are reflected in the descending set, and vice-versa. Syntax: public NavigableSet<E> descendingSet() Returns:…

Read More TreeSet descendingSet() method in java

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

Read More TreeSet descendingIterator() method in java

Let’s learn TreeMap tailMap(K fromKey, boolean inclusive) method in java. TreeMap tailMap(K fromKey, boolean inclusive) method in java tailMap(K fromKey, boolean inclusive) method of TreeMap class returns a view of the portion of this map whose keys are greater than (or equal to, if inclusive is true) fromKey. Syntax: public NavigableMap<K, V> tailMap(K fromKey, boolean…

Read More TreeMap tailMap(K fromKey, boolean inclusive) method in java

Let’s learn TreeMap tailMap(K fromKey) method in java. TreeMap tailMap(K fromKey) method in java tailMap(K fromKey) method of TreeMap class returns a view of the portion of this map whose keys are greater than or equal to fromKey. Syntax: public SortedMap<K, V> tailMap(K fromKey) Parameters: fromKey low endpoint (inclusive) of the keys in the returned…

Read More TreeMap tailMap(K fromKey) method in java

Let’s learn TreeMap subMap(K fromKey, K toKey) method in java. TreeMap subMap(K fromKey, K toKey) method in java subMap(K fromKey, K toKey) method of TreeMap class returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive. Syntax: public SortedMap<K, V> subMap(K fromKey, K toKey) Parameters: fromKey low…

Read More TreeMap subMap(K fromKey, K toKey) method in java