Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Iterator;
import java.util.TreeSet;

public class Main {
    public static void main(String[] args) {

        TreeSet<Integer> treeadd = new TreeSet<Integer>();

        treeadd.add(1);
        treeadd.add(3);
        treeadd.add(17);
        treeadd.add(2);

        System.out.println("First element is: " + treeadd.pollFirst());

        Iterator<Integer> iterator = treeadd.iterator();

        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}