This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 38045
    
  22
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: throws clause doubt in exception handling ?
 
Similar Threads
neither action class called nor jsp page displayed
exception handling
Exception
Null pointer exception ?
OCP JP Practice Exam 2 #29