This class implements Set and extends Set interface and supported by a hash table. It maintains the order of elements in collection.A collection that contains no duplicate elements. this implementation is not synchronized
package collection.demos;
import java.util.LinkedHashSet;
public class LinkedHashSetDemo {
public static void main(String[] args) {
LinkedHashSet hs = new LinkedHashSet();
hs.add("a");
hs.add("b");
hs.add("c");
hs.add("c");
hs.add("d");
hs.add("d");
System.out.println("Elements : " + hs);
}
}
package collection.demos;
import java.util.LinkedHashSet;
public class LinkedHashSetDemo {
public static void main(String[] args) {
LinkedHashSet hs = new LinkedHashSet();
hs.add("a");
hs.add("b");
hs.add("c");
hs.add("c");
hs.add("d");
hs.add("d");
System.out.println("Elements : " + hs);
}
}
Comments