Skip to main content

Posts

Showing posts from October, 2013

When to use "Transient" keyword

/** Transient used to mark a variable not to be serialized So if you are serializing an object and you don't want to serialize a partecular variable value inside it, Then you just make it as transient and it will not be serialized Below example explains this concept */ package javabeat.samples; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; class NameStore implements Serializable{ private String firstName; private transient String middleName; private String lastName; public NameStore (String fName, String mName, String lName){ this .firstName = fName; this .middleName = mName; this .lastName = lName; } public String toStr