1. public class Foo implements java.io.Serializable {2. private int x;3. public int getX() { return x; }4. publicFoo(int x){this.x=x; }5. private void writeObject( ObjectOutputStream s)6. throws IOException {7. /* insert code here*/8. }9. }
s.writeInt(x);
s.serialize(x);
s.writeObject(x);
s.defaultWriteObject();