在這個例子中,爲什麼使用空的「返回」(在catch塊中)? (對不起,我的英語) 提前謝謝!在這個例子中,爲什麼使用空迴歸?
public class DeserializeDemo
{
public static void main(String [] args)
{
Employee employee;
try
{
ObjectInputStream in = new ObjectInputStream(new FileInputStream("E:\\serialization\\employee.ser"));
employee = (Employee) in.readObject();
in.close();
}catch(IOException i)
{
i.printStackTrace();
return; //this one
}catch(ClassNotFoundException c)
{
System.out.println("Employee class not found");
c.printStackTrace();
return; //...and this one!
}
System.out.println("Deserialized Employee...");
System.out.println("Name: " + employee.name);
}
}
可能重複[在Java中的void方法中返回關鍵字做什麼?](http://stackoverflow.com/questions/744676/what-does-the-return-keyword-do-in-a- void-method-in-java) –