I was wondering how Java accepts the following script
public static void main(String[] args) throws IndexOutOfBoundsException, CoordinateException, MissionException, SQLException, ParserConfigurationException { try { doSomething(); } catch (Exception e) { e.printStackTrace(); } }
In the above code, I declare that the main function throws many different exceptions, but inside this function I catch a general exception. I am wondering how Java accepts this internally? For example, doSomething() throws an IndexOutOfBounds exception, e.printStackTrace () is called in the last catch (Exception e) {...} block?
I know if an exception not declared in the function's throwing area is thrown, try / catch will handle it, but what about the exceptions mentioned in the declaration?
source share