logoNEURAL COOK
SearchAll PostsTagsNotesAuthor
logoNEURAL COOK

A posts created with Next.js and Tailwind.css

Explore

  • All posts
  • Notes
  • Snippets
  • Tags
  • RSS feed

Connect

instagramtwitterfacebookyoutubelinkedinmailgithub

© 2026 VIKI. All rights reserved.

Built with
Contents
ArraysData StructuresListMath OperationBinary SearchSortingString Operation
Snippets/java

List

1 min read
On this pageReverse List
Reverse ListAdd element at index

# Reverse List

The most common and efficient way to reverse a list in Java is using the Collections.reverse()

import java.util.*;
 
List&lt;String&gt; 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.

List&lt;String&gt; list = new ArrayList<>(Arrays.asList("1", "2", "3"));
List&lt;String&gt; reversedView = list.reversed(); // ["3", "2", "1"]

# Add element at index

Can add element at index using

// add element to the front
list.add(0,nums[i]);
←PreviousData StructuresNext→Math Operation

On this page

Reverse ListAdd element at index