How to handle exception in Java?

Java ‘throws’ the result of an Exception to a specific section of code, a try-catch block. What...?

  • Java ‘throws’ the result of an Exception to a specific section of code, a try-catch block. What would be some alternatives? (Hint: consider the language ‘C, how does it handle errors’? Hint: maybe return a specific number denoting an error code inline with your code?) What is the result of that approach? Are there other approaches you might suggest?

  • Answer:

    You just want to use this kind of structure in your try/catch code: try{ x = a/b; } catch(Kind Of Error You Are Receiving){ } There isn't really a way to circumvent this, other than using if/else statements, though that would be more complicated.

Studio at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.