0

How can i call two different methods in a single try catch

java program

9th Feb 2018, 4:50 AM
NARESH BABU PATAKARLA
NARESH BABU PATAKARLA - avatar
2 odpowiedzi
+ 1
MyObject myObj = new MyObject(); try { myObj.myFunction1(); myObj.myFunction2(); } catch(Exception e) { // do something } // if you meant handle two errors // in different ways you can use // multiple catch try { myObj.myFunction1(); myObj.myFunction2(); } catch(IOException e1) { // do something } catch(NullPointerException e2) { // do other things }
9th Feb 2018, 6:27 AM
Leonardo Medai Cossutta
Leonardo Medai Cossutta - avatar
0
thanks
9th Feb 2018, 7:16 AM
NARESH BABU PATAKARLA
NARESH BABU PATAKARLA - avatar