📄 finallytest.java
字号:
// 例3.1.6 FinallyTest.java
public class FinallyTest
{
public static void main(String[] args)
{
while(true)
{
int result = 23;
int count = (int)(Math.random()*10);
try
{
result = result/count;
System.out.println("No exception");
} catch(ArithmeticException e){
System.out.println("Exception thrown");
e.printStackTrace();
}finally{
System.out.println("in finally clause");
if(count == 1) break; // out of "while"
}
System.out.println("result = "+result);
System.out.println("----------------");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -