Java LinkedHashSet() Constructor
Syntax
LinkedHashSet() constructor from LinkedHashSet has the following syntax.
public LinkedHashSet()
Example
In the following code shows how to use LinkedHashSet.LinkedHashSet() constructor.
/* w w w .j a v a2 s. com*/
import java.util.LinkedHashSet;
public class Main {
public static void main(String[] args) {
LinkedHashSet<Integer> lhashSet = new LinkedHashSet<Integer>();
System.out.println("Size of LinkedHashSet : " + lhashSet.size());
lhashSet.add(new Integer("1"));
lhashSet.add(new Integer("2"));
lhashSet.add(new Integer("3"));
System.out.println(lhashSet.size());
lhashSet.remove(new Integer("1"));
System.out.println(lhashSet.size());
}
}
The output:
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »