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