Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.HashSet;
import java.util.Set;

public class Main {
    /**
     * Convert the given array into a {@link Set}.  Changes to elements in the
     * set "write through" to the original array.
     *
     * @param array The array to convert or <code>null</code> for none.
     * @return Returns a new {@link Set} or <code>null</code> if
     * <code>null</code> was given for the array argument.
     */
    public static <T> Set<T> asSet(T[] array) {
        if (array == null)
            return null;
        final HashSet<T> set = new HashSet<T>();
        for (T element : array)
            set.add(element);
        return set;
    }
}