class Parent implements Serializable{
........
}
class Child extends Parent{
private void writeObject(ObjectOutputStream oos) throws IOException {
throw new NotSerializableException();
}
private void readObject(ObjectOutputStream oos) throws IOException {
throw new NotSerializableException();
}
}
上記のコードはSerializable
、親が既に実装されている場合に子が回避する方法を示していますSerializable
。それは悪い設計で、いくつかの点で混乱しているように見えるので、どのような状況でそれを行うことを検討しますか?