To reverse a list in Java, use the
Collections.reverse
method.Here's how you do it:
List<String> list = Arrays.asList("one", "two", "three");
Collections.reverse(list);
System.out.println(list); // [three, two, one]
Collections.reverse
method.Here's how you do it:
List<String> list = Arrays.asList("one", "two", "three");
Collections.reverse(list);
System.out.println(list); // [three, two, one]