Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.*;

public class Main {
    public static <T> LinkedHashSet<T> createLinkedHashSet() {
        return new LinkedHashSet();
    }

    public static <T, V extends T> LinkedHashSet<T> createLinkedHashSet(V... args) {
        if ((args == null) || (args.length == 0)) {
            return new LinkedHashSet();
        }
        LinkedHashSet<T> set = new LinkedHashSet(args.length);
        for (V v : args) {
            set.add(v);
        }
        return set;
    }

    public static <T> LinkedHashSet<T> createLinkedHashSet(Iterable<? extends T> c) {
        LinkedHashSet<T> set;
        if ((c instanceof Collection)) {
            set = new LinkedHashSet((Collection) c);
        } else {
            set = new LinkedHashSet();
            iterableToCollection(c, set);
        }
        return set;
    }

    private static <T> void iterableToCollection(Iterable<? extends T> c, Collection<T> list) {
        for (T element : c) {
            list.add(element);
        }
    }
}