认可的一天

import  java.io.Externalizable;

import java.io.IOException;

import java.io.ObjectInput;

import java.io.ObjectOutput;

public class Person implements Externalizable{

  private String name;

private int age;

  public Person(){}

  public Person(String name, int age){

    this.name=name;

    this.age=age;

}

  public String toString(){

    return"性别:"+this.name+:";年龄:"+this.age;

}

  public void readExternal(ObjectInput in)throws IOException,

    ClassNotFoundException{

  this.name=(String)in.readObject();

  this.age=in.readInt();

}

  public void writeExternal(ObjectOutput out)throws IOException{

  out.writeObject(this.name);

  out.writeInt(this.age);

}

}

猜你喜欢

转载自www.cnblogs.com/l2760186162/p/10951844.html
今日推荐