This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why Exceptions are handled in java?  RSS feed

 
siva chaitanya
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Added indentation]

In the above code, developer only wrote a wrong syntax and he only handled the Arithmetic Exception. Why to write irrelevant code we can remove those lines of code instead of handling the exception with try and catch.
 
Rohan Deshmkh
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The above program was developed because he(the developer) wanted to explain the concept of exception handling.
Many times the user would not be giving value himself, and at that time this concept may come to help.
 
changu mani
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most Applications are not simple enough. It is difficult to ensure that inputs go correct all the time.
 
Campbell Ritchie
Sheriff
Posts: 53769
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
siva chaitanya wrote: . . . In the above code, developer only wrote a wrong syntax . . .
That is not incorrect syntax. It is unusual logic.

You have already had a good explanation from Rohan Deshmkh, so there is no point my repeating it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!