Hi i created a method to save object in a file
public void findAndStore(String filename, double amount) { //1
File f1 = new File (filename); //2
FileOutputStream fos =new FileOutputStream (f1);//3
ObjectOutputStream os =new ObjectOutputStream (fos);//4
for (int i=0;i<nbApartment;i++){//5
if (ar_Apartment[i].get_Electcharge()<amount){//6
os.writeObject(ar_Apartment[i]);//7
}
}
os.close ();//8
}
it says in the line 3 error unhandled exception File not found exception , why i already created it and named it f1 .
it says in the line 4 ,7 ,8 unhandled exception type IO exception ,why .
NOTE: i already solved the problem by making the method throws exception or try and catch but my question is why there is an exception my teacher wrote it like this and he did't say anything about exceptions in this method .