All standard implementations of java.util.List
already implement java.io.Serializable
.
So even though java.util.List
itself is not a subtype of java.io.Serializable
, it should be safe to cast the list to Serializable
, as long as you know it's one of the standard implementations like ArrayList
or LinkedList
.
If you're not sure, then copy the list first (using something like new ArrayList(myList)
), then you know it's serializable.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…