Treeset
Monday, 6 June 2011
/ retrieving sorted and unique data from database using treeset
package com.centris.atr.util;
import java.util.Iterator;
import java.util.TreeSet;
public class TreeSort {
/**
* @param args
*/
public static void main(final String[] args) {
TreeSet treeset = new TreeSet();
treeset.add("Lincoln");
treeset.add("Clinton");
treeset.add("Obama");
treeset.add("Obama");
treeset.add("Regan");
treeset.add("Washington");
treeset.add("Bush");
System.out.println("TreeSet with Prez:");
Iterator iterator = treeset.iterator();
while (iterator.hasNext()) {
Object object = iterator.next();
System.out.println(object);
}
}
}
package com.centris.atr.util;
import java.util.Iterator;
import java.util.TreeSet;
public class TreeSort {
/**
* @param args
*/
public static void main(final String[] args) {
TreeSet treeset = new TreeSet();
treeset.add("Lincoln");
treeset.add("Clinton");
treeset.add("Obama");
treeset.add("Obama");
treeset.add("Regan");
treeset.add("Washington");
treeset.add("Bush");
System.out.println("TreeSet with Prez:");
Iterator iterator = treeset.iterator();
while (iterator.hasNext()) {
Object object = iterator.next();
System.out.println(object);
}
}
}
0 comments:
Post a Comment