I have a class that implements Serializable
. When I serialize members of that class, there are certain variables/methods that I don't to want included in the serialized representation.
Consider a Name
class that is Serializable
:
class Name implements Serializable {
private String firstName;
private String middleName;
private String lastName;
...
}
Suppose I want the serialized form of each instance to exclude the middleName
property.
Is there any way I can exclude particular properties and methods from being included in the serialized representation of the object?
transient keyword is used before variables whom you dont want to be serialized
eg.
private transient yourvariable;
and also transient cant be used with methods its for variables only
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