LinkedHashset
1. Introduced in 1.4 v
2. Duplicate objects are not allowed if we are trying to insert duplicate values then we wont get any compilation errors an won't get any Execution errors simply add method return false.
3. Null insertion is possible
4. Heterogeneous objects are allowed
5. The under laying data structure is linkedList & hashTable.
6. Insertion order is preserved.
7. It is a child class of HashSet.
Constructors of Java LinkedHashSet class
1.LinkedHashSet set=new LinkedHashSet()
This constructs a new, empty linked hash set with the default initial capacity (16) and load factor (0.75).
2 LinkedHashSet set=new LinkedHashSet(Collection c)
This constructs a new linked hash set with the same elements as the specified collection.
3 LinkedHashSet set=new LinkedHashSet(int initialCapacity)
This constructs a new, empty linked hash set with the specified initial capacity and the default load factor (0.75).
4 LinkedHashSet set=new LinkedHashSet(int initialCapacity, float loadFactor)
This constructs a new, empty linked hash set with the specified initial capacity and load factor.
LinkedHashSet program
import java.util.*; 
class Test 
{ 
public static void main(String[] args) 
{ 
LinkedHashSet h=new LinkedHashSet(); 
h.add("a"); 
h.add("a"); 
h.add("aaaa"); 
h.add(10); 
h.add(null); 
System.out.println(h); 
} 
}
Output :
[a,a,aaaa,10,null]