关于java自定义序列化方法的调用问题
一个简单的自定义序列化:比如我要对Student类序列化,它实现了Serializable接口,然后在Student类里重写了private void writeObject(java.io.ObjectOutputStream out) throws IOException 方法和private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException 方法,然后在main方法中测试序列化和反序列化的时候,为什么调用方法的时候是ObjectOutputStream的对象的引用oos.writeObject?既然writeObject在Student中定义了,为什么不用Student的对象调用该方法?从Student的方法定义中来看,oos不应该是作为参数的吗?
总之,就是说,为什么在Student里写了方法writeObject,调用的时候却用oos,那么在Student里写这个writeObject还有什么用?readObject同理。