Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.ArrayList;
import java.util.Collections;
import java.util.TreeSet;
import java.util.List;
import java.util.Set;

public class Main {

    public static TreeSet copySet(List ls) {
        TreeSet s = new TreeSet();
        s.addAll(ls);
        return s;
    }

    public static void main(String[] args) {
        List ls = new ArrayList();
        ls.add(1);
        ls.add(1);
        ls.add(2);
        ls.add(5);
        ls.add(4);
        ls.add(4);

        TreeSet s1 = copySet(ls);
        System.out.println(ls);
        System.out.println(s1);

    }

}