快捷导航

try catch中分return问题

像下面这样,当try\catch和方法内都有return语句时,为什么会报错public int test(){ try{ return 1; }catch(){ return 2 ; }return 3;}

免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。

版权声明:作者保留权利,不代表本站立场。

回复

使用道具 举报

参与会员2

try和catch中都含有return时,“return 3;”这句不会被执行到
回复

使用道具 举报

返回了多个return语句,编译不通过
回复

使用道具 举报

可能感兴趣的问答

发新帖
  • 微信访问
  • 手机APP