Answers for "how to flip a list in java"

1

how to flip a list in java

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
 
// Program to in-place reverse a list in Java
class Main
{
    public static void main(String[] args)
    {
        List<String> colors = new ArrayList<>(Arrays.asList("RED", "BLUE", "BLACK"));
 
        Collections.reverse(colors);
        System.out.println(colors);
    }
}
Posted by: Guest on April-09-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language