import java.io.*;
public class
test implements java.io.Serializable{
static int i;
int j;
public static void main(
String args[]) throws Exception{
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(new File("txtfile")));
test t1 = new test();
t1.i=5;
t1.j=10;
out.writeObject((Object)t1);
out.flush();
out.close();
ObjectInputStream in = new ObjectInputStream(new FileInputStream(new File("txtfile")));
//t1.i=2;
//t1.j=5;
test t = (test)in.readObject();
System.out.println(t.i);
System.out.println(t.j);
in.close();
}
}
Output: 5
10
If u remove comments and execute
Output: 2
10
This means static field are serializable