This Java Example shows how to get the tail set values from the Set.
Get tailSet values of Java SortedSet Example
This Java Example shows how to get the tail set values from the Set. The tail set contains the elements of the set which is greater than the specified set value.We use tailSet(E fromElement) method of SortedSet interface. It returns a view of the portion of this set whose elements are greater than or equal to fromElement.
Example:- TailSetSortedSet.java
package devmanuals.com; import java.util.*; public class TailSetSortedSet { public static void main(String args[]) { SortedSet Sset = new TreeSet(); Sset.add("Gyan"); Sset.add("Ankit"); Sset.add("Arun"); Sset.add("Anand"); Sset.add("Ram"); System.out.println("The SortedSet entries is as follows : " + Sset); System.out.println("The tail set of the set is : " + Sset.tailSet("Gyan")); } }
Output:-
The SortedSet entries is as follows : [Anand, Ankit, Arun, Gyan, Ram]
The tail set of the set is : [Gyan, Ram] |
[ 0 ] Comments