What is the scope of a try/catch? Essentially I am deserializing some objects and creating new references to store them in. Once they are loaded, I tried to use a method in the references but am given the below compiling error.
try{
ObjectInputStream is = new ObjectInputStream(new FileInputStream("saveGame.ser"));
gameCharacter oneRestore = (gameCharacter) is.readObject();
gameCharacter twoRestore = (gameCharacter) is.readObject();
gameCharacter threeRestore = (gameCharacter) is.readObject();
} catch (Exception ex) {ex.printStackTrace();}
System.out.println("One's type is: " + oneRestore.getType());
System.out.println("Two's type is: " + twoRestore.getType());
System.out.println("Three's type is: " + threeRestore.getType());
The compilation error is:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
oneRestore cannot be resolved
twoRestore cannot be resolved
threeRestore cannot be resolved