2 ms·
If you use LinkedList and ArrayList in an API, you can't pass a list created by the following factory methods: Collections.emptyList() Collections.singletonL
by haglin 9y 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.