Here you can find the source of stackToList(Stack
public static <T> List<T> stackToList(Stack<T> stack)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; import java.util.Stack; public class Main { public static <T> List<T> stackToList(Stack<T> stack) { List<T> list = new ArrayList<>(); while (!stack.isEmpty()) list.add(stack.pop());/*from www.j a v a 2 s . c o m*/ return list; } }