我有几行java代码
class FileManager
{
File f = new File("SD.DAT");
public void wsv(ArrayList<Student> list) throws IOException
{
try
{
FileOutputStream fos = new FileOutputStream(f);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(list);
fos.close();
oos.close();
}
catch (FileNotFoundException ex)
{
Logger.getLogger(FileManager.class.getName()).log(L evel.SEVERE, null, ex);
}
}
public ArrayList<Student> rsv() throws ClassNotFoundException, IOException
{
if (!f.exists())
{
return new ArrayList<SinhVien>();
}
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(f));
return (ArrayList<Student>) ois.readObject();
}
}
我想问:在下面的代码中,什么是:
public void wsv(ArrayList<Student> list)
public ArrayList<Student> rsv()
意思是?
为什么它必须返回(ArrayList<Student>) ois.readObject();
我不了解数组,所以我希望你能告诉我。
太感谢了!