RandomAccess is a marker interface. It doesn't define methods; instead, it identifies a class as having a particular capability.
According to the online document:
To be more specific, for typical instances of the class, this loop:
runs faster than this loop:
The well-known implementing classes are:
ArrayList, Stack, Vector
According to the online document:
The primary purpose of this interface is to allow generic algorithms
to alter their behavior to provide good performance when applied to
either random or sequential access lists.
To be more specific, for typical instances of the class, this loop:
for (int i=0, n=list.size(); i < n; i++)
list.get(i);
runs faster than this loop:
for (Iterator i=list.iterator(); i.hasNext(); )
i.next();
The well-known implementing classes are:
ArrayList, Stack, Vector
本文解析了RandomAccess接口的作用及其在不同列表实现中的性能优势。该接口作为一种标记接口,旨在标识具备随机访问能力的类,使得泛型算法可以根据列表的具体类型调整行为以优化性能。
210

被折叠的 条评论
为什么被折叠?



