What are the circumstances under which a finally {} block will NOT execute?

前端 未结 9 2047
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 01:45

In a Java try{} ... catch{} ... finally{} block, code within the finally{} is generally considered \"guaranteed\" to run regardless of what occurs

9条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 02:39

    The only times finally won't be called are:

    if the power turns off

    1. if you call System.exit()
    2. if the JVM crashes first
    3. if there is an infinite loop in the try block
    4. if the power turns off

提交回复
热议问题