try catch finally执行顺序

无return时:try -> catch ->finally

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

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

posted @ 2022-07-28 21:57  小九很着急  阅读(70)  评论(0)    收藏  举报