我收到此错误:
Error:(5, 9) java: cannot find symbol
symbol: class Employee
location: class Student
Error:(5, 24) java: cannot find symbol
symbol: class Employee
location: class Student
嗨,我正在用Java编写一个可序列化的程序,但这给了我这个错误,请您解决一下并告诉我这是什么问题吗?
帮助将不胜感激!
这是我的源代码:
import java.io.*;
public class Student{
public static void main(String[] args) throws Exception{
Employee e=new Employee(221, "My name is Rajendra Arora");
FileOutputStream fout=new FileOutputStream("D://raj1.txt");
ObjectOutputStream out=new ObjectOutputStream(fout);
out.writeObject(e);
out.flush();
System.out.println("Success....");
}
}
最佳答案
确保Java文件都在同一目录中
例如:
myDirectory/Employee.java
myDirectory/Student.java
关于java - 在可序列化编程中收到错误 “cannot find symbol”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23367965/