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 clone()
? Or should I always do the completely redundant extra check?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…