问题描述
为什么不能?为什么采用对象
?
推荐答案
这是因为 writeObject
in ObjectOutputStream
覆盖 /docs/api/java/io/ObjectOutput.html\"rel =noreferrer> ObjectOutput
界面,不要求对象 Serializable
。
This is because writeObject
in ObjectOutputStream
overrides the method in the ObjectOutput
interface which does not require that the object be Serializable
.
ObjectOutput
接口指定允许对象的方法写入流或底层存储,但这可以通过序列化以外的过程实现。 ObjectOutputStream
实现了此功能,但需要可序列化的对象。但是,它无法修改它实现的接口的签名。
The ObjectOutput
interface specifies methods that allow objects to be written to a stream or underlying storage, but this may be achieved by a process other than serialization. The ObjectOutputStream
implements this functionality, but requires serializable objects. However, it cannot modify the signature of the interface that it implements.
这篇关于为什么ObjectOutputStream.writeObject不采用Serializable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!