how to flip a list in java

Solutions on MaxInterview for how to flip a list in java by the best coders in the world

showing results for - "how to flip a list in java"
Greta
14 Aug 2017
1import java.util.ArrayList;
2import java.util.Arrays;
3import java.util.Collections;
4import java.util.List;
5 
6// Program to in-place reverse a list in Java
7class Main
8{
9    public static void main(String[] args)
10    {
11        List<String> colors = new ArrayList<>(Arrays.asList("RED", "BLUE", "BLACK"));
12 
13        Collections.reverse(colors);
14        System.out.println(colors);
15    }
16}