Recent Posts
- NCC Punjab LDC Results 2013 NCCPunjab.com Interview Selected Candidates List
- RGUHS PGSSET Super Speciality 2013 Exam www.logisys.net.in Online Application
- RKCL RS-CIT Results 2013 rkcl.in RSCIT Final Exam May Result 2013
- TNEB Electricity Bills Online Payment tnebnet.org/awp/login Tamilnadu EB Payment System
- Kerala LET 2013 Fee Structure for 2013-14 Engineering College Admission
Discussion Forum
TreeSet Example in Java
TreeSet Example in Java Collection Framework. This Java TreeSet example describes the basic operations performed on the TreeSet in Collection Framework.
TreeSet Example in Java Collection Framework. This Java TreeSet example describes the basic operations performed on the TreeSet in Collection Framework.
Program:
import java.util.TreeSet;
import java.util.Iterator;
public class TreeSetDemo {
public static void main(String[] args) {
TreeSet ts = new TreeSet();
ts.add(“A”);
ts.add(“E”);
ts.add(“C”);
ts.add(“B”);
ts.add(“D”);
System.out.println(“TreeSet: “+ts);
Iterator it = ts.iterator();
System.out.print(“TreeSet-element: “);
while(it.hasNext())
System.out.print(” “+it.next());
}
}
Result:
TreeSet: [A, B, C, D, E]
TreeSet-element: A B C D E
