Why does Java have transient fields?

Posted by Editorial Staff | Updated on

The Java transient keyword is used on class attributes/variables to indicate that serialization process of such class should ignore such variables while creating a persistent byte stream for any instance of that class.

The transient keyword in Java is used to indicate that a field should not be part of the serialization (which means saved, like to a file) process. In this example, the thumbnailImage is a thumbnail image that is generated by invoking the generateThumbnail method.


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers