Name
RandomAccess
Synopsis
This marker interface is implemented by
List
implementations to advertise that they
provide efficient (usually constant time) random access to all list
elements. ArrayList
and Vector
implement this interface, but LinkedList
does not.
Classes that manipulate generic List
objects may
want to test for this interface with instanceof
and use different algorithms for lists that provide efficient random
access than they use for lists that are most efficiently accessed
sequentially.
public interface RandomAccess {
}
Implementations
ArrayList
, Vector
,
java.util.concurrent.CopyOnWriteArrayList
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.