
Concepts of Multithreading 7.13
Example 7.8: OwnException.java A Program to Show How to Throw Our Own
Exception
1.
package com.oops.chap7;
2. import java.lang.Exception;
3. class OurOwnException extends Exception{
4. OurOwnException(){} // default constructor
5. OurOwnException(String stg){super(stg);} // constructor with arg
6. }// end of own exception
7. class OwnException1{
8. public static void main(String[] args) {
9. double credits = 20000.00;
10. double debits = 19900.00;
11. try{
12. if ( ( credits-debits)<1000.00 )
13. throw new OurOwnException(“Sorry Transaction can not be
processed. Bal is <1000.00”);
14. else
15. System.out.println(“Transaction ...