This content has been marked as final. Show 2 replies
It would have been better if this interface had been called RandomAccessList, to more clearly define its scope.
Lists provide sequential access, as well as access based on an index number (i.e. random access). Some implementations are much more efficient in providing the latter. These implementations are marked with the RandomAccess interface, for reasons explained in the RandomAccess API docs (optimization for sorting algorithms, primarily).
For maps, random access is pretty much a given, i.e. the entire purpose of a map is to provide key-based access to its values. So it's pointless to specify a RandomAccess interface for maps, as all maps would implement this by definition.
It goes a little further than this. Those two Lists (ArrayList, Vector) are the only List implementations in the Collections that offer constant-time access to any element, which is what this marker requires. A LinkedList must be traversed to find the desired item, so the retrieval time is proportional to the list's size. ArrayList and Vector are array-backed, and arrays allow direct access.