Wednesday, 18 January 2017

TreeSet : FloorMethod






import java.util.TreeSet;

public class FloorMethod {

    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.floor(30));
        System.out.println("Ceiling(56) "+ts1.floor(56));
       
        System.out.println(" returns less than or equal to the given element,\n or null if no such element. ");
       
    }
}

No comments:

Post a Comment