flip a list in java code example
Example: 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);
}
}