Transient variables cannot be serialized. The fields marked transient in a serializable object will not be transmitted in the byte stream. An example would be a file handle or a database connection. Such objects are only meaningful locally. So they should be marked as transient in a serializable class.
view plaincopy to clipboardprint? class Sample implements Serializable {
private int number; //gets serialized private String name; //gets serialized private [B]transient[/B] Connection con = null; // does not get serialized