This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Resolved: exceptions names  RSS feed

Ranch Hand
Posts: 217
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have some issues with the name .My exercise tell some exceptions to name it like this : InvalidGpException .Can i give every name i want to an exceptions? this name i give it on a method? on a class?where?and i have the power to name with what name i want?

when i write throw i refer to a class or i can refer to a method?
Posts: 64496
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your exception classes should always extend java.lang.Exception but maybe indirectly; you can extend a subclass of Exception. The name of an exception class should always say what it is used for, and should always end “Exception”. You should look through the existing kinds of Exception to find the best kind of Exception to extend.
You can only throw a (non‑null) instance of Throwable, which of course includes any instances of its subclasses. Nothing else.

Look in the documentation for Exception to find some different kinds of Exception. If you want an unchecked Exception, look at the subclasses of RuntimeException. For more details, you have already been given a link to the appropriate Java™ Tutorials section.
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
how do I do my own kindle-like thing - without amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!