A Return inside and outside an If Statement

前端 未结 2 759
忘了有多久
忘了有多久 2021-02-10 01:56

This is probably a fairly easy question to answer, but it has been bugging me some time.

If there is a return statement inside an if statement, inside a method (in the J

2条回答
  •  庸人自扰
    2021-02-10 02:27

    Only the first return statement hit is used. The method then terminates.

    There are some code conventions that frown on multiple return statements because they might be hard to read, but I'm not one of them. :)

提交回复
热议问题