
本教程操作环境:windows7系统、java10版,DELL G3电脑。
1、过程
(1)要求次类是可序列化的: 实现Serializable接口
(2)要求类的属性同样的要实现Serializable接口
(3)使用static或transient修饰的属性, 不可实现序列化
(4)提供一个版本号
2、实例
classPersonimplementsSerializable{
privatestaticfinalLongserialVersionUID=67348253671L;
privateStringname;
privateIntegerage;
privateDogdog;
publicPerson(Stringname,Integerage,Dogdog){
this.name=name;
this.age=age;
this.dog=dog;
}
}
classDogimplementsSerializable{
privateStringname;
publicDog(Stringname){
this.name=name;
}
}原文来自:https://www.py.cn © 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END















































暂无评论内容