treeset java amount of members code example
Example 1: java treeset
import java.util.*;
Set<String> movies = new TreeSet<String>();
movies.add(E);
movies.add("The Shining");
movies.add("Dawn of the Dead");
movies.add("Zombieland");
Example 2: TreeSet
TreeSet ensemble = new TreeSet();
Comparator comparateur = new Comparateur();
TreeSet ensemble = new TreeSet(comparateur);
public class Comparateur implements Comparator {
public int compare(Object obj1, Object obj2){
return ((Comparable)obj2).compareTo(obj1);
}
public boolean equals(Object obj){
return this.equals(obj);
}
}