• Post Reply Bookmark Topic Watch Topic
  • New Topic

Wondering about using Exceptions  RSS feed

 
Lucky Lam
Greenhorn
Posts: 10
Android Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Can you please tell me what's wrong with the code above? Do we have to identify exactly what kind of exception? and why?
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What makes you think something's wrong? Are you getting some sort of error message?

It's often a better approach to catch the specific exceptions you're worried about. But in a case where you really do want to catch all possible exceptions (e.g. if you want to log them all) that's how you'd do it.

...or at least, it would be if you'd spelled printStackTrace() correctly. Watch your capitals.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!