 import  java.io.*;
import  java.io.*;
 public class Throwable implements Serializable ...{
public class Throwable implements Serializable ...{
 /** *//** use serialVersionUID from JDK 1.0.2 for interOperability */
    /** *//** use serialVersionUID from JDK 1.0.2 for interOperability */ PRivate static final long serialVersionUID = -3042686055658047285L;
    PRivate static final long serialVersionUID = -3042686055658047285L;

 /** *//**
    /** *//** * Native code saves some indication of the stack backtrace in this slot.
     * Native code saves some indication of the stack backtrace in this slot. */
     */ private transient Object backtrace;
    private transient Object backtrace;  private String detailMessage;
    private String detailMessage; private Throwable cause = this;
    private Throwable cause = this; private StackTraceElement[] stackTrace;
    private StackTraceElement[] stackTrace; 
    
 public Throwable() ...{
    public Throwable() ...{ fillInStackTrace();
        fillInStackTrace(); }
    }

 public Throwable(String message) ...{
    public Throwable(String message) ...{ fillInStackTrace();
        fillInStackTrace(); detailMessage = message;
        detailMessage = message; }
    }

 public Throwable(String message, Throwable cause) ...{
    public Throwable(String message, Throwable cause) ...{ fillInStackTrace();
        fillInStackTrace(); detailMessage = message;
        detailMessage = message; this.cause = cause;
        this.cause = cause; }
    }

 public String getLocalizedMessage() ...{
    public String getLocalizedMessage() ...{ return getMessage();
        return getMessage(); }
    }

 public Throwable getCause() ...{
    public Throwable getCause() ...{ return (cause==this ? null : cause);
        return (cause==this ? null : cause); }
    }

 public synchronized Throwable initCause(Throwable cause) ...{
    public synchronized Throwable initCause(Throwable cause) ...{ if (this.cause != this)
        if (this.cause != this) throw new IllegalStateException("Can't overwrite cause");
            throw new IllegalStateException("Can't overwrite cause"); if (cause == this)
        if (cause == this) throw new IllegalArgumentException("Self-causation not permitted");
            throw new IllegalArgumentException("Self-causation not permitted"); this.cause = cause;
        this.cause = cause; return this;
        return this; }
    }

 public String toString() ...{
    public String toString() ...{ String s = getClass().getName();
        String s = getClass().getName(); String message = getLocalizedMessage();
        String message = getLocalizedMessage(); return (message != null) ? (s + ": " + message) : s;
        return (message != null) ? (s + ": " + message) : s; }
    }

 private synchronized StackTraceElement[] getOurStackTrace() ...{
    private synchronized StackTraceElement[] getOurStackTrace() ...{ // Initialize stack trace if this is the first call to this method
        // Initialize stack trace if this is the first call to this method
 if (stackTrace == null) ...{
        if (stackTrace == null) ...{ int depth = getStackTraceDepth();
            int depth = getStackTraceDepth(); stackTrace = new StackTraceElement[depth];
            stackTrace = new StackTraceElement[depth]; for (int i=0; i < depth; i++)
            for (int i=0; i < depth; i++) stackTrace[i] = getStackTraceElement(i);
                stackTrace[i] = getStackTraceElement(i); }
        } return stackTrace;
        return stackTrace; }
    } //......省略了一些
//......省略了一些 }
}
 public class MyException extends Exception
public class MyException extends Exception
 ...{
...{ MyException(String str)
MyException(String str)
 ...{
    ...{ super(str);
    super(str); }
    } }
}
 public  class MyTest
public  class MyTest
 ...{
...{ public void f()throws MyException
public void f()throws MyException
 ...{
    ...{ throw new MyException("f() exception");
    throw new MyException("f() exception"); }
    } }
} public class Main
public class Main
 ...{
...{ public static void main(String[]args)
    public static void main(String[]args)
 ...{
    ...{ try
        try
 ...{
        ...{ new MyTest().f();
            new MyTest().f(); }catch(MyException me)
        }catch(MyException me)
 ...{
        ...{ System.out.println(me);
            System.out.println(me); }finally
        }finally
 ...{System.out.println("finally");
        ...{System.out.println("finally"); }
        } }
    } }
} #include<iostream>
#include<iostream> using namespace std;
using namespace std;
 #ifndef NULL
#ifndef NULL #define NULL 0
#define NULL 0 #endif
#endif class MyException
class MyException
 ...{
...{ const char * const msg;
      const char * const msg; public:
      public:
 MyException(const char* const _msg=NULL):msg(_msg)...{};
             MyException(const char* const _msg=NULL):msg(_msg)...{}; void print()
             void print()
 ...{
             ...{ cout<<msg<<endl;
                  cout<<msg<<endl; }
             } };
}; void f()
void f()
 ...{
...{ throw MyException("something bad happened");
     throw MyException("something bad happened"); }
}
 int main()
int main()
 ...{
...{ try
    try
 ...{
    ...{ f();
    f(); }catch(MyException me)
    }catch(MyException me)
 ...{
    ...{ me.print();
    me.print(); }
    } system("pause");
  system("pause"); return 0;
  return 0; }
}新聞熱點
疑難解答