This is some information on the Java 6 certification that I prepare. This information is not very well structured and it is most of the time an answer to the questions that come when I read the SCJP 6 book (Bates and Sierra). *** AS OF 5 OF MARCH 2010, I AM SCJP 6.0 ***

Saturday, February 6, 2010

30 - Treeset - Java 1.6.0_18

package javaapplication15;

import java.util.Set;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) {

        Set treeSet = new TreeSet();

        treeSet.add("2"); treeSet.add("4"); treeSet.add("6"); treeSet.add("8");

        System.out.println("first : " + ((TreeSet)treeSet).first());
        System.out.println("floor(6) : " + ((TreeSet)treeSet).floor("6"));
        System.out.println("higher(6) : " + ((TreeSet)treeSet).higher("6"));
        System.out.println("last : " + ((TreeSet)treeSet).last());
    }

}



first : 2
floor(6) : 6
higher(6) : 8
last : 8

No comments:

Post a Comment

Followers