java: how to use clone() and what about the cast check
问题 This code: class RawStringIterator { java.util.Stack<State> stateStack = new java.util.Stack<State>(); RawStringIterator(RawStringIterator i) { stateStack = (java.util.Stack<State>) i.stateStack.clone(); } /* ... */ } gives me this warning: Type safety: Unchecked cast from Object to Stack<Utils.OperatorTree.RawStringIterator.State> I guess I can ignore the warning here. But I wonder about how to use clone() in general? Do I always have to use a @SuppressWarnings("unchecked") every time I use