-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLinkedHashMapDemo.java
More file actions
38 lines (29 loc) · 914 Bytes
/
LinkedHashMapDemo.java
File metadata and controls
38 lines (29 loc) · 914 Bytes
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
33
34
35
36
37
38
import java.util.*;
class LinkedHashMapDemo
{
public static void main(String args[])
{
LinkedHashMap linkedHashMap = new LinkedHashMap();
linkedHashMap.put("Prabhu",100);
linkedHashMap.put("Deep",200);
linkedHashMap.put("Singh",300);
linkedHashMap.put("Banga",400);
System.out.println(linkedHashMap);
System.out.println(linkedHashMap.put("Prabhu",100));
Set set = linkedHashMap.keySet();
System.out.println(set);
Collection collection = linkedHashMap.values();
System.out.println(collection);
Set entrySet = linkedHashMap.entrySet();
System.out.println(entrySet);
Iterator itr = entrySet.iterator();
while(itr.hasNext())
{
Map.Entry mapEntry = (Map.Entry) itr.next();
System.out.println(mapEntry.getKey()+", "+mapEntry.getValue());
if(mapEntry.getKey().equals("Prabhu"))
mapEntry.setValue(1000);
}
System.out.println(linkedHashMap);
}
}