Wednesday, 18 January 2017

TreeSet : CeilingMethod







import java.util.TreeSet;

public class CeilingMethod {

    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("Ceiling(20) "+ts1.ceiling(20));
        System.out.println("Ceiling(40) "+ts1.ceiling(40));
      
        System.out.println("The ceiling() method returns the least element in this set greater than or equal to the given element,\n or null if there is no such element ");
      
      
    }
}

No comments:

Post a Comment