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.
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
class GalleryImage implements Serializable
private Image image;
private transient Image thumbnailImage;
private void generateThumbnail()
// Generate thumbnail.
private void readObject(ObjectInputStream inputStream)
throws IOException, ClassNotFoundException
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.