I use the following code to restore Vector:
objects = new Vector<Object>((Collection<Object>) state.getSerializable(EXTRA_OBJECTS));
It prevents java.lang.ClassCastException and maintains the order of the elements.
To restore the stack, you can use the following code:
stack = new Stack<Object>(); stack.addAll((Collection<Object>) state.getSerializable(EXTRA_STACK));
It works due to the fact that Vector, Stack, ArrayList extend Collection, and you can make your serialized object in Collection and go to the Stack method or Vector addAll ().
Nik
source share