sample code to demonstrate TreeSet class
// TreeSet Demo application
package collection;
import java.util.TreeSet;
public class TreeSetDemo {
public static void main(String[] args)
{
TreeSet l=new TreeSet();
l.add(new Integer(30));
l.add(new Integer(10));
l.add(new Integer(40));
//l.add(new Integer(30));duplicates are not added
System.out.println(l);
}
}
output:
[10, 30, 40]
0 comments:
Post a Comment