This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Could someone tell me where to find the information for this question?

 
kenny gill
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The question I'm being asked:

I do not want to look at documentation to see if the methods I use cause exceptions. If there is a problem, there are two distinct ways that Java will let me know. What are they?
 
Ishan Pandya
Ranch Hand
Posts: 226
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess they are "catch" and "throws".
 
Campbell Ritchie
Sheriff
Posts: 48404
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You do need to look at the documentation, which should tell you. Look at this constructor and this method, for example. Note the unchecked Exception in one case appears only in the Javadoc and the checked Exception in the other case appears as a throws clause, too.
Note that unexpected unchecked Exceptions might not be listed at all; if you pass 0 and suffer an ArirthmeticException, that might not be anticipated or recorded.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic