java4all@1986 java. Powered by Blogger.

What is user Defined Exception?

>> Monday, May 30, 2011

User defined exceptions may be implemented by defining a new exception class by extending the Exception class.
           look the example:
public class MyException extends Exception {
/* class definition of constructors goes here */
public MyException() {
super();
}
public MyException (String errorMessage) {
super (errorMessage);
}
}

Throw and/or throws statement is used to signal the occurrence of an exception. To throw an exception:
throw new MyException(“I threw my own exception.”)
To declare an exception: public myMethod() throws MyException {…}
.

0 comments:

Post a Comment

FaceBook Login

HTML/JAVASCRIPT

HTML/JAVASCRIPT

HTML/JAVASCRIPT

HTML/JAVASCRIPT

Total Pageviews

STATCOUNTER

  © Blogger template Simple n' Sweet by Ourblogtemplates.com 2009

Back to TOP