Java Stack to stackToList(Stack stack)

Here you can find the source of stackToList(Stack stack)

Description

stack To List

License

Open Source License

Declaration

public static <T> List<T> stackToList(Stack<T> stack) 

Method Source Code


//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;
    }
}

Related

  1. stack2String(Stack stack)
  2. stackToTuple(Stack s)