Here you can find the source of reverse(List
Parameter | Description |
---|---|
list | a parameter |
public static <T> List<T> reverse(List<T> list)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { /**/*from w ww. j av a2 s.c o m*/ * Method to reverse the list * * @param list * @return {@link List<T>} */ public static <T> List<T> reverse(List<T> list) { if (list != null && list.size() > 0) { List<T> updatedList = new ArrayList<>(); for (int i = list.size() - 1; i >= 0; i--) { updatedList.add(list.get(i)); } return updatedList; } return null; } }