Answer to Question #63007 in Java | JSP | JSF for jonney

Question #63007
what is meant by giving a variable within a class variable a transient attribute?
1
Expert's answer
2016-11-03T16:16:09-0400
transient is a Java keyword which marks a member variable not to be serialized when it is persisted to streams of bytes. When an object is transferred through the network, or saved on a hard drive the object needs to be 'serialized'. Serialization converts the object state to serial bytes. Those bytes are sent over the network and the object is recreated from those bytes. Member variables marked by the java transient keyword are not transferred; they are lost intentionally.

In an object you may have information that you don't want to serialize (a stored password or any private information), or perhaps it doesn't make sense to serialize (a reference to a parent factory object). Marking these as 'transient' means the serialization mechanism will ignore these fields.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS