I read that static variables are not saved during serilazation ,but
in the following code i belive that value of satic variable is
saved.please help me.
class a
{
static int i=10;
public a()
{
i+=10;
}
public static void main(String []avg)
{
try{
ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream
a a1=new a();
oos.writeObject(a1);
ObjectInputStream ois=new ObjectInputStream(new FileInputStream
(("c:\\test\\a.set"));
a a2;
a2=ois.readObject();
System.out.pritnln(a2.i);
}catch(Exception e){System.out.println(e);}
}
}
i got output as: 20.