List¶
Reverse List¶
The most common and efficient way to reverse a list in Java is using the Collections.reverse()
import java.util.*;
List<String> list = new ArrayList<>(Arrays.asList("A", "B", "C"));
Collections.reverse(list); // list is now ["C", "B", "A"]
Java 21+
Introduced in Java 21 as part of the Sequenced Collections API, this method returns a reversed view of the original list.
Add element at index¶
Can add element at index using