Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General 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: 48910
58
  • 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