Create new LinkedHashSet from Array - Java java.util

Java examples for java.util:Set Creation

Description

Create new LinkedHashSet from Array

Demo Code


//package com.java2s;

import java.util.Arrays;

import java.util.LinkedHashSet;

public class Main {
    public static <E> LinkedHashSet<E> newLinkedHashSet(E... elements) {
        if (elements == null) {
            throw new NullPointerException();
        }/*w w w .j  ava  2  s  . c  o  m*/
        return new LinkedHashSet<E>(Arrays.asList(elements));
    }
}

Related Tutorials