For instance:
public String showMsg(String msg) throws Exception {
if(msg == null) {
throw new Exception("Message is null");
}
//Create message anyways and return it
return "DEFAULT MESSAGE";
}
String msg = null;
try {
msg = showMsg(null);
} catch (Exception e) {
//I just want to ignore this right now.
}
System.out.println(msg); //Will this equal DEFAULT MESSAGE or null?
I'm needing to essentially ignore exceptions in certain cases (usually when multiple exceptions can be thrown from a method and one doesn't matter in a particular case) so despite the pathetic example that I used for simplicity will the return in showMsg still run or does the throw actually return the method?
question from:https://stackoverflow.com/questions/15962228/java-does-throwing-an-exception-kill-its-method