1 //异常类
 2 package st;
 3 public class example_1
 4 {
 5     public static void main(String args[])
 6     {
 7         int n=0,m=0,t=1000;
 8         try
 9         {
10             m=Integer.parseInt("8888");
11             n=Integer.parseInt("ab89");
12             t=7777;  //t没有机会被赋值
13         }
14         catch(NumberFormatException e)
15         {
16           System.out.println("发生异常:"+    e.getMessage());
17         }
18         System.out.println("n="+n+",m="+m+",t="+t);
19         try
20         {
21             System.out.println("故意抛出I/O异常!");
22             throw new java.io.IOException("我是故意的"); //故意抛出异常
23             
24         }
25         catch(java.io.IOException e)
26         {
27           System.out.println("发生异常:"+e.getMessage());
28         }
29     }
30 }
View Code

相关文章:

  • 2022-01-07
  • 2021-10-16
  • 2022-01-11
  • 2021-12-17
  • 2021-08-24
  • 2021-12-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-22
  • 2021-09-28
相关资源
相似解决方案