Java TreeSet tailSet(E fromElement, boolean inclusive) Method Example

The tailSet(E fromElement) method of  java.util.TreeSet class returns a view of the portion of this set whose elements are greater than or equal (if inclusive is true) to fromElement. The returned set is backed by this set, so changes in the returned set are reflected in this set, and vice-versa. The returned set supports all optional set operations that this set supports.

[Read more…]

Java TreeSet subSet(E fromElement, E toElement) Method Example

Previously we have seen about subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) method of java.util.TreeSet class which returns a view of the portion of this set whose elements range from fromElement to toElement. whereas subSet(E fromElement, E toElement) method returns a view of the portion of this set whose elements range from fromElement(inclusive) upto toElement(exclusive)

[Read more…]

Java TreeSet subSet() Method Example

The subSet(E fromElement, boolean fromInclusive, E toElement, boolean toInclusive) method of java.util.TreeSet class returns a view of the portion of this set whose elements range from fromElement to toElement. If fromElement and toElement are equal, the returned set is empty unless fromInclusive and toInclusive are both true

[Read more…]