On 3/26/2020 1:16 PM, Alonso Del Arte wrote:
My question is just this: was it also this way in NetBeans 8.2, or am I remembering incorrectly?

Just a guess. If you use the same variable name for the three cases does it work then?

-ernie


When I was writing up this toy example with NetBeans 11.2:
int dividend = 47;
        int divisor = 0;
        try {
            int result = dividend / divisor;
            System.out.println(dividend + " / " + divisor + " = " + result);
        } catch (ArithmeticException ae) {
            System.out.println(ae.getMessage());
        } catch (RuntimeException re) {
            System.out.println(re.getMessage ());
        } catch (Exception e) {
            System.out.println(e.getMessage ());
        }
I thought NetBeans would suggest multi-catch. This is definitely not a shining example of how to handle exceptions, and the IDE should be smart enough to recognize the three exceptions are being handled exactly alike. On the other hand, the point of this toy example is to show how the inheritance hierarchy affects the ordering of the Catch clauses, and perhaps NetBeans thinks these are placeholders for more specialized exception handlers I'll get around to writing later.

In another toy example, involving IllegalArgumentException and ArithmeticException, I do see that NetBeans 11.2 does suggest multi-catch.

Al

--
Alonso del Arte
Author at SmashWords.com <https://www.smashwords.com/profile/view/AlonsoDelarte>
Musician at ReverbNation.com <http://www.reverbnation.com/alonsodelarte>



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to