Java try catch blocks -
here simple question :
what think of code use try catch every instruction ?
void myfunction() { try { instruction1(); } catch (exceptiontype1 e) { // code } try { instruction2(); } catch (exceptiontype2 e) { // code } try { instruction3(); } catch (exceptiontype3 e) { // code } try { instruction4(); } catch (exceptiontype4 e) { // code } // etc }
i know that's horrible, want know if decreases performance.
try this: (i know doesn't answer question, it's cleaner)
void myfunction() { try { instruction1(); instruction2(); instruction3(); instruction4(); } catch (exceptiontype1 e) { // code } catch (exceptiontype2 e) { // code } catch (exceptiontype3 e) { // code } catch (exceptiontype4 e) { // code } // etc }
Comments
Post a Comment