„Szerializalas jegyzet” változatai közötti eltérés
| 12. sor: | 12. sor: | ||
public Object writeReplace() throws ObjectStreamException { | public Object writeReplace() throws ObjectStreamException { | ||
A a = new A(); a.x = 5; a.y = 6; return a; | A a = new A(); a.x = 5; a.y = 6; return a; | ||
} | |||
} | |||
=== OOT - 2015. június 9. === | |||
public class A implements Serializable { | |||
private transient int x = 8; | |||
public int y = 4; | |||
public A () { x = 0; y = 4; } | |||
private static final ObjectStreamField[] serialPersistentFields = { new ObjectStreamField("x", Integer.TYPE) }; | |||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException{ | |||
in.defaultReadObject(); | |||
x = y + 4; | |||
} | } | ||
} | } | ||