import java.util.LinkedHashMap;
public class MainClass {
public static void main(String[] args) {
LinkedHashMap linkedMap = new LinkedHashMap();
for (int i = 0; i < 10; i++) {
linkedMap.put(i, i);
}
System.out.println(linkedMap);
// Least-recently used order:
linkedMap = new LinkedHashMap(16, 0.75f, true);
for (int i = 0; i < 10; i++) {
linkedMap.put(i, i);
}
System.out.println(linkedMap);
for (int i = 0; i < 7; i++)
// Cause accesses:
System.out.println(linkedMap.get(i));
System.out.println(linkedMap);
}
}
{0=0, 1=1, 2=2, 3=3, 4=4, 5=5, 6=6, 7=7, 8=8, 9=9}
{0=0, 1=1, 2=2, 3=3, 4=4, 5=5, 6=6, 7=7, 8=8, 9=9}
0
1
2
3
4
5
6
{7=7, 8=8, 9=9, 0=0, 1=1, 2=2, 3=3, 4=4, 5=5, 6=6}