当finall块中包含return语句时,Eclipse会给出警告“finally block does not complete normally”,原因分析如下:
1、不管try块、catch块中是否有return语句,finally块都会执行。
2、finally块中的return语句会覆盖前面的return语句(try块、catch块中的return语句),所以如果finally块中有return语句,Eclipse编译器会报警告“finally block does not complete normally”。
3、如果finally块中包含了return语句,即使前面的catch块重新抛出了异常,则调用该方法的语句也不会获得catch块重新抛出的异常,而是会得到finally块的返回值,并且不会捕获异常。
结论,
finally 内部使用 return 语句是一种很不好的习惯,如果try中还有return语句,它会覆盖了try 区域中 return 语句的返回值,程序的可读性差
面对上述情况,其实更合理的做法是,既不在 try block 内部中使用 return 语句,也不在 finally 内部使用 return 语句,而应该在 finally 语句之后使用 return 来表示函数的结束和返回
相关推荐
This is the default action if dest does not exist, or if no filesystem is on it -keep-as-directory If one source directory is specified, create a root directory containing that directory, ...
does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable ...
What does not 不连接互联网时,会发生自动退出的情况。 Do not connect to the Internet, will automatically withdraw from the case. What was not tested 把文字转换成swf文件。 Text to swf file. ...
- **Reversing wait() and notify():** Reversing the order of `obj.wait()` and `obj.notify()` might not cause the method to complete normally because `wait()` must be called within a synchronized block ...
on their semantics, but does not fully define the semantics. The library also contains built-in functions and exceptions — objects that can be used by all Python code without the need of an import ...
标题中的"Normally-open-switch.rar_The Open Road"指的是一个与常开开关相关的程序或文档,可能涉及电子工程或自动化控制领域。常开开关,也称为NO(Normally Open)开关,是指在无外力作用时触点处于断开状态的...
be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of ...
be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of ...
问题 连接到集群后,JVM不会退出。 我该如何重现? 启动redis集群。 docker run -e "IP=0.0.0.0" -p 7000-7005:7000-7005 grokzen/redis-cluster:latest 然后运行: make test
Compil32 does not do the actual compilation itself it relegates it to ISCmplr.dll. If the ISCmplr project is changed, you normally don t need to recompile Compil32 since it s essentially a text ...
files which do not fit fully into a block, are NOT by default packed into fragments. To illustrate this, a 100K file has an initial 64K block and a 36K remainder. This 36K remainder is not packed into...
Assuming the page reference does not result in an access violation, a page fault can be either hard or soft. A hard page fault results in a read from disk, either a page file or memory-mapped file. A...
卡士妥常闭电磁阀Castel_Normally-closed-solenoid-valves_14-E
string.sub(s, -3) will return the last 3 bytes of the string which is not necessarily the same as the last three characters of the string, and may or may not be a complete code. You could use the ...
4. 当InnoDB尝试恢复时,它发现数据库没有正常关闭("Database was not shutdown normally!"),并且需要进行崩溃恢复。 5. 日志中提到“Restoring possible half-written data pages”,表明InnoDB正在尝试从双写...
用法 df [-F FSType] [-abeghklntVvZ] [-o FSType 特定选项] [目录 | 块设备 | 资源] df -k 以kbytes显示文件大小的查看文件系统方式 六、显示文件内容 more 分屏显示文件的内容。 用法 more [-cdflrsuw] [-行...
At a minimum, you will need a breadboard and two digital multimeters, but normally you will also need an oscilloscope and a signal generator. Two of these experiments are called "optional" and are in...
c) recognizes filters with serial numbers > 60000 (normally VariLC numbers) d) supports binary transfer of >127 bytes Previous release 1.11 Release date September 8, 2003 Known bugs a) implicit ...
The Class Library Reference usually does not describe inherited member functions, inherited operators, and overridden virtual member functions. For information on these functions, refer to the base ...