小弟初学JAVA 遇到点问题不知道怎么产生的这个个问题
代码如下:
import java.io.Serializable;
class Student implements Serializable
{
int id;
String name;
int age;
public Student(int id,String name,int age)
{
this.id=id;
this.name=name;
this.age=age;
}
}
public class Seriazlization
{
public static void main(String[] args) throws Exception
{
Student stu1 = new Student(19,"zhangsan",25);
Student stu2 = new Student(20,"lisi",24);
FileOutputStream fos = new FileOutputStream("student.txt");
ObjectOutputStream os = new ObjectOutputStream(fos);
os.writeObject(stu1);
os.writeObject(stu2);
os.close();
FileIntputStream fis = new FileIntputStream();
ObjectIntputStream ois = new ObjectOutputStream(fis);
stu1 =(Student)ois.readObject();
stu2 =(Student)ois.readObject();
ois.close();
System.out.println("id" + stu1.id);
System.out.println("name" + name.id);
System.out.println("age" + age.id);
System.out.println("id" + stu2.id);
System.out.println("name" + stu2.name);
System.out.println("age" + stu2.age);
}
}
错误:
D:\学习环境\bin>javac Serialization.java
error: cannot read: Serialization.java
1 error