It marks the implementations of list which can be accessed randomly.
This way a caller can either access the data randomly if that is efficient, or use another means if it is not.
e.g. In AbstractList you have an implementation which can be optimised for RandomAccess or not.
public List<E> subList(int fromIndex, int toIndex) {
return (this instanceof RandomAccess ?
new RandomAccessSubList<>(this, fromIndex, toIndex) :
new SubList<>(this, fromIndex, toIndex));
}
What algorithm is JVM implementing for faster access?
The important method is get(int)
which needs to be O(1)
public E get(int index) {
rangeCheck(index);
return elementData(index);
}
calls
E elementData(int index) {
return (E) elementData[index];
}
as you can see it just looks up the index in an array so it O(1)