I'm having trouble with some java code. The program consists of about 7 files, but I will try to keep it short.
I'm trying to load an ArrayList from a file into a variable, with ObjectStream. It gave me a warning, because all the compiler could see, was that I said an Object should be casted to ArrayList. of course the compiler won't know what kind of object there is in the file. As the coder I know that the file can only consist of one ArrayList and nothing else. So I searched the web, and found out to supress the warning, nut now it give me the error:
Schedule.java:34: error: <identifier> expected
To give you a picture of what's happening, here is the code the error happens in. This error shouldn't be affected by any of the other classes
import java.util.*;
import java.io.*;
public class Schedule
{
private static ArrayList<Appointment> schedule;
private static File file;
private static ObjectInputStream objIn;
private static boolean exit;
private static Scanner in = new Scanner(System.in);
public static void main(String[] args)
{
initializeSchedule();
System.out.println("Welcome!");
while(!exit){
System.out.print("write command: ");
Menu.next(in.next());
}
}
public static void initializeSchedule()
{
try{
file = new File("Schedule.ca");
if(!file.exists()){
schedule = new ArrayList<Appointment>();
}
else{
objIn = new ObjectInputStream(new FileInputStream("Schedule.ca"));
@SuppressWarnings("unchecked")
schedule = (ArrayList<Appointment>)objIn.readObject();
objIn.close();
}
} catch (IOException e){
System.out.println("Exception thrown :" + e);
} catch (ClassNotFoundException e){
System.out.println("Exception thrown :" + e);
}
}
public static void exit()
{
exit = true;
}
public static ArrayList<Appointment> getSchedule()
{
return schedule;
}
}
the error is in initializeSchedule, right under the supression, where schedule is set to the ObjectStream input.