java中为什么要实现Serializable接口

1530阅读 0评论2014-06-15 tkchks
分类:Java

实现序列号接口(Serializable),标记这个类可以被序列化。 “I’m fine to be serialized”.

当你尝试序列化没有实现Serializable接口的对象时,将会抛出异常 NotSerializableException.

The idea is to be able to transparently serialize instances of the class – potentially for caching or other purposes, I’m not sure in this case. The serialVersionUID field is just part of the versioning that Java binary serialization uses.

参考:

上一篇:每个servlet只有一个实例,怎样保证servlet是线程安全
下一篇:java中实现回调callback