finally必须和try一起使用 try catch finally哪个可有可无?

try catch finally哪个可有可无?配对方法1:try{}catch{}配对方法2:try{}catch{}finally{}配对方法3:try{}finally{}因此可以看出,catc

try catch finally哪个可有可无?

配对方法1:try{}catch{}配对方法2:try{}catch{}finally{}配对方法3:try{}finally{}因此可以看出,catch和finally都不是必需的,try和catch也不是必须配对的,但是如果有try,则必须选择一对,catch或finally,或者两者都是