Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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: 228
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess they are "catch" and "throws".
 
Campbell Ritchie
Sheriff
Posts: 53763
127
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!