aspose file tools*
The moose likes Java in General and the fly likes throws clause doubt in exception handling ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "throws clause doubt in exception handling ?" Watch "throws clause doubt in exception handling ?" New topic
Author

throws clause doubt in exception handling ?

siva chaitanya
Ranch Hand

Joined: Jul 05, 2011
Posts: 59
throws clause throws the exception to where and how ? and also please explain difference between throws and throw ?

Thanks in advance
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Please go through the Oracle tutorials on Exceptions - Throwing Exceptions

Do please SearchFirst. This question about Exceptions has been asked a lot many times.
siva chaitanya
Ranch Hand

Joined: Jul 05, 2011
Posts: 59
throw new userdefinedexception(); is this valid? Can we give any names for an exception using throw keyword.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

siva chaitanya wrote:throw new userdefinedexception(); is this valid? Can we give any names for an exception using throw keyword.


What happened when you tried it?
siva chaitanya
Ranch Hand

Joined: Jul 05, 2011
Posts: 59
i got it jeff we can give eny names by extending Exception class
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38398
    
  23
But your names should conform to standard naming conventions, example here, and end with Exception. If you want to throw an Exception because an empty String has been passed, it should be called EmptyStringException. You should also go through the hierarchy of Exceptions, because there might be a better superclass than Exception.
 
Consider Paul's rocket mass heater.
 
subject: throws clause doubt in exception handling ?