Stack out = new ArrayStack(); while (!in.empty()) { Object elt = in.pop(); out.push(elt); } return out;