import java.io.*;
class Dog implements Serializable
{
Collar col;
int dogSize;
Dog(Collar c,int s)
{
col=c;
dogSize=s;
}
public Collar getCollar()
{
return col;
}
}
class Collar
{
int collarSize;
//Collar theCollar;
Collar(int s)
{
collarSize=s;
}
public int getCollarSize()
{
return collarSize;
}
}
class Testcollar
{
public static void main (String [] args)
{
Collar thecollar = new Collar(3);
Dog d=new Dog(thecollar,5);
System.out.println(d.getCollar().getCollarSize());
try
{
FileOutputStream fs= new FileOutputStream("tttestcollar.ser");
ObjectOutputStream os=new ObjectOutputStream(fs);
os.writeObject(d);
os.close();
}catch(Exception e){}
try
{
FileInputStream fis=new FileInputStream("tttestcollar.ser");
ObjectInputStream ois=new ObjectInputStream(fis);
d=(Dog)ois.readObject();
ois.close();
}catch(Exception e){}
System.out.println(d.getCollar().getCollarSize());
}
}