Comment se fait-variable statique est Sérialisé?

public class MySerializable implements Serializable{

    private int x=10;
    private static int y = 15;
    public static void main(String...args){
        AnotherClass a = new AnotherClass();
        AnotherClass b;
        //Serialize
        try {
            FileOutputStream fout = new FileOutputStream("MyFile.ser");
            ObjectOutputStream Oout = new ObjectOutputStream(fout);
            Oout.writeObject(a);
            System.out.println( a.toString());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        //De-serialize
        try {
            FileInputStream fis = new FileInputStream("MyFile.ser");
            ObjectInputStream  Oin = new ObjectInputStream (fis); 
            b = (AnotherClass) Oin.readObject();
            System.out.println( b.toString());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }catch (ClassNotFoundException e){
            e.printStackTrace();
        }

    }
}

class AnotherClass  implements Serializable{  

    transient int x = 8;  
    static int y = 9;  

    @Override  
    public String toString() {  
        return "x : " + x + ", y :" + y;  
    }  
}

Pouvez-vous s'il vous plaît dites-moi comment la variable statique est sérialisé ??

OriginalL'auteur Girish Nair | 2012-10-08