Creating your own Exceptions in Java
Java defines several built-in classes for exception handling. All these classes are a part of the java.lang package which is automatically imported. That is why, while throwing an exception you did not specifically include any package for exception classes.
Apart from the built-in exception classes you can define your own exception classes. This is very useful when you want to define exception types which are having a behavior different from the standard exception type, particularly when you want to do validations in your application. The example given below created and used in the same, lava file, but it is possible to create and store exception type in packages and use them elsewhere.
|All times are GMT +5.5. The time now is 12:38.|