import java.io.*;
class Person implements Serializable
{
public static final long serialVersionUID = 42L;//UID固定可以在修改成员时还能被序列化
static String country="cn";
private String name;
transient int age;//这样修饰后打印结果年龄为0,因为加了transient后,年龄不能被序列化了
Person(String name,int age,String country)
{
this.name = name;
this.age = age;
this.country=country;
}
public String toString()
{
return name+":"+age+country;
}
} |