Java LinkedHashSet(int initialCapacity, float loadFactor) Constructor

Syntax

LinkedHashSet(int initialCapacity, float loadFactor) constructor from LinkedHashSet has the following syntax.

public LinkedHashSet(int initialCapacity,    float loadFactor)

Example

In the following code shows how to use LinkedHashSet.LinkedHashSet(int initialCapacity, float loadFactor) constructor.

 
//ww w. j  ava  2  s .  co  m
import java.util.Arrays;
import java.util.LinkedHashSet;

public class Main {
  public static void main(String[] args) {

    LinkedHashSet linkedHashSet = new LinkedHashSet(10,0.75F);

    linkedHashSet.add("1");
    linkedHashSet.add("2");
    linkedHashSet.add("java2s.com");

    Object[] objArray = linkedHashSet.toArray();
    System.out.println(Arrays.toString(objArray));
  }
}

 

The output: