其他分享
首页 > 其他分享> > try catch finally执行顺序

try catch finally执行顺序

作者:互联网

无return时:try -> catch ->finally

有return时:返回值在catch语句时,先执行完finally语句再执行catch语句,要有变量在finally改变,catch中有临时变量存储未修改的返回值,执行完finally语句后返回临时变量存储得值。

返回值在finally语句中,直接执行到finally语句就返回,catch的return作废。

标签:语句,return,try,finally,catch,返回值,执行
来源: https://www.cnblogs.com/fcx0723/p/16530413.html