Wednesday, 18 January 2017

TreeSet : TailSet




import java.util.TreeSet;

public class TailSet {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        TreeSet<Integer> ts1 = new TreeSet<>();   
        ts1.add(36);
        ts1.add(48);
        ts1.add(24);
        ts1.add(64);
       
        System.out.println("Full-List (Duplicate Not Allowed && Maintain Ascending Order in TreeSet) : "+ts1);
       
        System.out.println("Tailset(20) "+ts1.tailSet(30));
        System.out.println("Tailset(40) "+ts1.tailSet(40));
       
        System.out.println(" returns a view of the portion of this set whose elements are strictly greater than toElement ");

    }
}

No comments:

Post a Comment