Skip to content

Commit 7efbe3a

Browse files
committed
update linkedhashmap-source-code.md
1 parent 07a0852 commit 7efbe3a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

docs/java/collection/linkedhashmap-source-code.md

+2
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ LRUCache < Integer, String > cache = new LRUCache < > (2);
118118
cache.put(1, "one");
119119
cache.put(2, "two");
120120
cache.put(3, "three");
121+
cache.put(4, "four");
121122
for (int i = 0; i < 4; i++) {
122123
System.out.println(cache.get(i));
123124
}
@@ -129,6 +130,7 @@ for (int i = 0; i < 4; i++) {
129130
null
130131
null
131132
three
133+
four
132134
```
133135

134136
从输出结果来看,由于缓存容量为 2 ,因此,添加第 3 个元素时,第 1 个元素会被删除。添加第 4 个元素时,第 2 个元素会被删除。

0 commit comments

Comments
 (0)