Skip to content

Commit 545d735

Browse files
authored
Update 这几道Java集合框架面试题几乎必问.md
1 parent b7a462e commit 545d735

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Java相关/这几道Java集合框架面试题几乎必问.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ public interface RandomAccess {
4444
```
4545
ArraysList 实现了 RandomAccess 接口, 而 LinkedList 没有实现。为什么呢?我觉得还是和底层数据结构有关!ArraysList 底层是数组,而 LinkedList 底层是链表。数组天然支持随机访问,时间复杂度为 O(1),所以称为快速随机访问。链表需要遍历到特定位置才能访问特定位置的元素,时间复杂度为 O(n),所以不支持快速随机访问。,ArraysList 实现了 RandomAccess 接口,就表明了他具有快速随机访问功能。 RandomAccess 接口只是标识,并不是说 ArraysList 实现 RandomAccess 接口才具有快速随机访问功能的!
4646

47-
**补充内容:RandomAccess接口**
48-
47+
4948
**下面再总结一下 list 的遍历方式选择:**
5049

5150
- 实现了RadmoAcces接口的list,优先选择普通for循环 ,其次foreach,

0 commit comments

Comments
 (0)