Skip to main content

Linkedhashset

Linkedhashset
  •  Linkedhashset is class which sub class of hashset.
  •  Linkedhashset is implemented based on hybrid data structure(hashing+linkedlist)
  •  Linkedhashset preserve insertion order
  • Duplicate object are not allowed, null insertion is allowed.
LinkedHashset Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 
public class Linkedhashset
{
 
   public static void main(String[] args)
	{
 
 
	 LinkedHashSet h1=new LinkedHashSet<>();
 
	h1.add("milan");
	h1.add("vivek");
	h1.add("abhi");
	h1.add("bl");
 
        System.out.println("size of linked hashset "+h1.size());
 
	for(Object o1:h1)
	{
		System.out.println(o1);
	}
 
   }
}
 
output:
 
size of linked hashset 4
milan
vivek
abhi
bl