
java program using transient variable

Hi Friend,
A transient variable is a variable that may not be serialized.The transient keyword indicates that the variable is not the part of the persistent state of the object. Variables that are part of the persistent state of an object must be saved when the object is archived.
Here is an example:
public class TransientVariable{
String name;
transient String pass;
public TransientVariable(String n, String p) {
this.name = n;
this.pass = p;
}
public String toString() {
return "Name=" + name + "\n Password=" + pass;
}
public static void main(String[] args) {
TransientVariable v=new TransientVariable("rose","roseindia");
String st= v.toString();
System.out.println(st);
}
}
For more information, visit the following link:
http://www.roseindia.net/help/java/t/transient-java-keyword.shtml
Thanks