⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lx7.java

📁 JAVA学习源代码,大家可以好好参考,请多提宝贵意见
💻 JAVA
字号:
public class Lx7
{
  static void demoproc()
  { //throw new Exception();
    try
    {
       throw new NullPointerException("demo");
       //System.out.println("not thow!");
    }
    
    catch(NullPointerException e)
    {
     System.out.println("Caught inside demoproc."+e);
     throw e;
    } 
    //throw new Exception();
   }
   public static void throwException() throws Exception{
   
   //try语句块产生一个异常
      try {
     System.out.println( "\n***Calling method throwException***\n" );
     throw new Exception();
     //throw new NullPointerException("demo");
         }

   //打印异常信息,并重新抛出异常
     catch ( Exception e ){
     	//catch(NullPointerException e){
     System.out.println(
               "Exception handled in static method throwException"+e );
     System.out.println("Rethrow the exception object " 
                                                                      + "in static method throwException");
     throw e;
    }
 }
   
   public static void main(String args[])
   {
    try
    {
    	throwException();
      //demoproc();
    }
    catch( Exception exception ){
     System.out.println("Exception handled in static method doesNotThrowException" );
     System.out.println("Does not Rethrow the exception object " 
                                                                     + "in static method doesNotThrowException");
   }
    try
    {
    	demoproc();
    }
    catch(NullPointerException e){System.out.println("Recaught:"+e);}
    
    //catch(Exception e){ System.out.println("already caught Exception!!"); }
   /* catch(NullPointerException e)
    {
     System.out.println("Recaught:"+e.toString());
    }*/
    
   } 
    }    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -