东莞茂荣假日酒店:JAVA 程序错在哪了?

来源:百度文库 编辑:高考问答 时间:2024/04/30 09:12:29
程序是练习对象流的 把对象写到文件中去
错在哪了?
import java.io.*;
public class Object implements Serializable{
int no,wage;
String name,sex;
public Object ( int no,String name,String sex,int wage)
{
this.no=no;this.wage=wage;this.name=name;this.sex=sex;
}
public String tostring()
{
return no+" "+name+" "+sex+" "+wage;
}
}

import java.io.*;
public class Testobject{
public static void main(String[] args) throws Exception
{
ObjectOutputstream oos=new ObjectOutputstream(new FileOutputstream("e:/Ob.ser"));
oos.writeObject(new Object(001,"才女","女",1000));
oos.flush();
oos.close();
}
}
程序报错:
Testobject.java:5: cannot resolve symbol
symbol : class ObjectOutputstream
location: class Testobject
ObjectOutputstream oos=new ObjectOutputstream(new FileOutputstream("e:/Ob.ser
"));
^
Testobject.java:5: cannot resolve symbol
symbol : class ObjectOutputstream
location: class Testobject
ObjectOutputstream oos=new ObjectOutputstream(new FileOutputstream("e:/Ob.ser
"));
^
Testobject.java:5: cannot resolve symbol
symbol : class FileOutputstream
location: class Testobject
ObjectOutputstream oos=new ObjectOutputstream(new FileOutputstream("e:/Ob.ser
"));
^
3 errors

ObjectOutputstream你都没有定义阿~~
你是不是想用FileOutputStream啊。。或者把ObjectOutputstream改为ObjectOutputStream看看~~