• Post Reply Bookmark Topic Watch Topic
  • New Topic

doubt on exception handling  RSS feed

 
manas ranjan mandal
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
without extending exception class can i create my own user-defined exception?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

By "exception classes" we usually mean, more precisely, subclasses of java.lang.Throwable, and by "user defined exception", we mean subclasses of any subclass of java.lang.Throwable. By these definitions, the answer is "no", and of course, it has to be.

But can you throw an exception without defining your own exception class? Absolutely -- you can throw any exception type defined in the APIs; for most of them, you can specify your own error message, making them "user defined" in some sense.
 
manas ranjan mandal
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for your valuable answe
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!