Hacker News new | ask | show | jobs
by haglin 3049 days ago
If you use LinkedList and ArrayList in an API, you can't pass a list created by the following factory methods:

Collections.emptyList() Collections.singletonList() Collections.unmodifiableList() List.of()

As niftich points out, use the marker interface java.util.RandomAccess, if you want to know if the list allows constant time access.