public class MyObj implements Serializable { private transient Map<String, Object> myHash = new HashMap<String, Object>(); ... }
Is there any way to ensure that when an object of the above class is deserialized the member myHash will be set to a new empty Map rather than be set to null?
public class MyObj implements Serializable { private transient Map<String, Object> myHash = new HashMap<String, Object>(); private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); myHash = new HashMap<String, Object>(); } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With