• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why Exceptions are handled in java?

 
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
Pie
Posts: 50175
79
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic