Hey!
I've a silly doubt regarding Exception.
When we're
handling an exception, what will happen after the exception is
caught. Will the JVM continue with the next line of code after doing what's in the
catch clause or will it stop there doing what's in the
catch clasue.
For e.g just look at this code:
import java.text.*;
import java.util.*;
class Dates3 {
public static void main(String[] args) {
Date d1 = new Date(1000000000000L);
try {
DateFormat[] dfa = new DateFormat[6];
dfa[0] = DateFormat.getInstance();
dfa[1] = DateFormat.getDateInstance();
dfa[2] = DateFormat.getDateInstance(DateFormat.SHORT);
dfa[3] = DateFormat.getDateInstance(DateFormat.MEDIUM);
dfa[4] = DateFormat.getDateInstance(DateFormat.LONG);
dfa[5] = DateFormat.getDateInstance(DateFormat.FULL);
dfa[6] = DateFormat.getDateInstance(DateFormat.DAY_OF_WEEK_FIELD); # 1
for (DateFormat df : dfa)
System.out.println(df.format(d1));
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Here 1 produces an
IllegalArgumentException and stops there.
Shouldn't the code continue as we're handling the exception ??