Set, TreeSet, Iterator in Java #Java Short Notes #Blog

/* * TreeSetExample.java * *Illustrates mathematical set operations * * Created on January 10, 2008, 9:28 PM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */package treesetexample;import java.util.Set;import java.util.TreeSet;import java.util.Iterator;/** * * @author Sayed */public class TreeSetExample {        /** Creates a new instance of TreeSetExample */    public TreeSetExample() {    }        //example set operations      public static void treeSetOperations() {        final int MAXIMUM = 20;        //create a TreeSet        Set ss = new TreeSet();        //store data in the set, set can contain only one type of data        for (int i = 0; i < MAXIMUM; i++) {            System.out.println("  - Storing Data(" + i + ")");            ss.add(new Integer(i));        }        //display set data using an iterator        Iterator it = ss.iterator();        while (it.hasNext()) {            System.out.println(it.next());        }    }            /**     * @param args the command line arguments     */    public static void main(String[] args) {        // TODO code application logic here        TreeSetExample treeSet = new TreeSetExample();        treeSet.treeSetOperations();    }    }

From: http://sitestree.com/?p=4789
Categories:Java Short Notes, Blog
Tags:
Post Data:2013-06-23 13:04:36

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada

Leave a Reply