1
JavaIntermediate#design-patterns
Implement writeObject() and readObject() methods in the class to control exactly what gets written/read, useful for encrypting sensitive fields or handling versioning logic beyond default field-by-field serialization.
private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.writeObject(encrypt(password));
}