public class Person implements Serializable{ //如果不序列化,对Object对象读写,会抛出NotSerializableException
private static final long serialVersionUID = 1L;
/* 22.08 序列化类的版本号
*
*/
private String name;
private int age;
private transient char sex; //transient关键字用于不需要序列化的属性
public Person() {
super();
}
public Person(String name, int age) {
super();
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public String toString() {
return "Perosn [name=" + name + ", age=" + age + "]";
} |
|