Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyException extends Exception
- {
- private static int exceptionNb = 0;
- public MyException(String exceptionString)
- {
- super(exceptionString);
- exceptionNb++;
- }
- public static int exceptionCount(){ return exceptionNb;}
- }
- class MyExceptionMain
- {
- public static void main(String[] args)
- {
- MyException e1= new MyException(new String("abcd"));
- System.out.println(e1.getMessage());
- System.out.println(e1.exceptionCount());
- e1 = new MyException("efgh");
- System.out.println(e1.getMessage());
- System.out.println(e1.exceptionCount());
- e1 = new MyException("klmn");
- System.out.println(e1.getMessage());
- System.out.println(e1.exceptionCount());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement