Java : RandomAccess with Examples
RandomAccess (Java SE 23 & JDK 23) in Java with Examples.
You will find code samples for most of the RandomAccess methods.
Summary
Marker interface used by List implementations to indicate that they support fast (generally constant time) random access. 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.
final var arrayList = new ArrayList<String>();
System.out.println(arrayList instanceof RandomAccess); // true
final var linkedList = new LinkedList<String>();
System.out.println(linkedList instanceof RandomAccess); // false
Related posts
- API Examples