SequencedCollection adds first/last access and reversed() to ordered collections.
List<String> list = new ArrayList<>(List.of("a", "b", "c"));
System.out.println(list.getFirst());
System.out.println(list.getLast());
System.out.println(list.reversed());
a
c
[c, b, a]
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-07-26