Sort the items of a Set and display the sorted elements.



package one;
import java.util.*;

public class SetItems {
public static void main(String[] args) {
Set<String> set = new TreeSet<String>();
set.add("Porkodi");
set.add("Anup");
set.add("Malu");
set.add("Mahendran");
set.add("RajKumar");
set.add("Saravana");
set.add("Viniston");

for (String item : set) {
System.out.println(item + " ");
}
}

}

Post a Comment

Copyright © Rough Record. Designed by OddThemes