reverse List of Integers - Java java.util

Java examples for java.util:List Operation

Description

reverse List of Integers

Demo Code


//package com.java2s;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class Main {
    public static void main(String[] argv) {
        List aList = java.util.Arrays.asList("asdf", "java2s.com");
        System.out.println(reverse(aList));
    }/*  w  ww . j a  v a 2  s  .com*/

    public static List<Integer> reverse(List<Integer> aList) {
        List<Integer> tmp = new LinkedList<>(aList);
        Collections.reverse(tmp);
        return tmp;
    }
}

Related Tutorials