I am Using LinkedHashMap for retaining inserted Order of data
My particular function contains This map...
Map retainOrder(){
Map map= new LinkedHashMap<Long,String>();
map.put(1L,"A");
map.put(2L,"B");
map.put(3L,"C");
map.put(4L,"D");
map.put(5L,"E");
return map;
}
I am getting output by calling retainOrder() function
1:A
2:B
3:c
4:D
5:E
This is As Expexted
But Sometimes it gives output
2:B
3:c
4:D
5:E
1:A
This is Not expected
the problem is that first key becomes last...this is LinkedHashMap doing something wrong. Please give me solution i want to retain order and first value should be first not last.