Program to Sort Set by using TreeSet(by default elements are sorted in ascending order), where elements are Integer type

TreeSet is sorted by natural order of elements (i.e. in ascending order).
import java.util.TreeSet;
import java.util.Set;
* @author AnkitMittal
* Copyright (c), AnkitMittal
* Main class
public class SortSet
   public static void main(String...a){
       Set<Integer> treeSet = new TreeSet<Integer>();
       System.out.println("treeSet : "+treeSet);
treeSet : [1, 2, 3]

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
//start paginationJs //end paginationJs