Kee Kee moon wrote:For example, if users enter a number that is less than 0. I like to use try and catch to handle exception.
It seems that I could not find a standard library for the exception handling.
Oh, it seems you have a very simple problem. If the requirement is like quoted above, then you could do with a simple if statement.
Although, it should be noted that this is a very generic example and it is NOT advised to use Exception class itself for throwing exceptions, a more specific Exception subclass would be more appropriate (the kind that Jasper suggested).
You'd best write your own exception class as demonstrated in the earlier post, that only caters to specific situations (in you case,
less than zero).
Also, please notice that you must use the "throws" keyword to declare the exception while declaring the method, otherwise compiler will complain.