Which code, inserted at line 14, will allow this class to correctly serialize and deserialize?
01. import java.io.*;
02. public class Foo implements Serializable {
03. public int x, y;
04. public Foo(int x, int y){
05. this.x = x; this.y = y;
06. }
07.
08. private void writeObject(ObjectOutputStream s)
09. throws IOException{
10. s.writeInt(x); s.writeInt(y);
11. }
12.
13. private void readObject(ObjectInputStream s)
14. throws IOException, ClassNotFoundException {
15. //insert code here
16. }
17. }
Comments