Java Collection Tutorial - Java LinkedHashSet(Collection <? extends E > c) Constructor








Syntax

LinkedHashSet(Collection <? extends E > c) constructor from LinkedHashSet has the following syntax.

public LinkedHashSet(Collection <? extends E > c)

Example

In the following code shows how to use LinkedHashSet.LinkedHashSet(Collection <? extends E > c) constructor.

// w  w  w  .j  av  a2 s  . c om

import java.util.LinkedHashSet;

public class Main {

  public static void main(String[] args) {
    LinkedHashSet<Integer> lhashSet = new LinkedHashSet<Integer>();

    lhashSet.add(new Integer("1"));
    lhashSet.add(new Integer("2"));
    lhashSet.add(new Integer("3"));

    LinkedHashSet<Integer> lhashSet2 = new LinkedHashSet<Integer>(lhashSet);
  }
}