Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Stack; public class Main { public static <T> void flipStack(Stack<T> stack) { ArrayList<T> tmp = new ArrayList<>(stack); stack.clear(); for (int i = tmp.size() - 1; i >= 0; i--) stack.push(tmp.get(i)); } }