java - Return value unaffected if Exception is thrown? -
if exception thrown inside method, return value left before?
for example:
public int test(int a) { throw new exception(); } and then:
a=2; a=test(a); ...after catch...
system.out.println(string.valueof(a)); //a=? is affected upon exception? seems logically not so(?) can't find info on though. neeed sure.
no, a not affected. declared in separate method test() method.
int = 2; try { = obj.test(a); } catch (exception e) { system.out.println(string.valueof(a)); } system.out.println(string.valueof(a)); both sop print 2.
Comments
Post a Comment