answersLogoWhite

0

The try is used to define a block of code in which exceptions may occur. This block of code is called a guarded region (which really means "risky code goes here"). One or more catch clauses match a specific exception to a block of code that handles it. Here's how it looks in pseudocode:

1. try {

2. // This is the "guarded region"

3. // All your bank database access code goes here

4. // And any other code that might process that data

5. // We may have many code lines here

6. }

7. catch(DatabaseDownException) {

8. // Put code here that handles this exception.

9. // Put the graceful error message here

10. // This is the last line of the exception handler.

11. }

12. catch(SomeOtherException) {

13. // Put code here that handles this exception

14. }

15.

16. // Some other unguarded code continues from here

User Avatar

Wiki User

11y ago

What else can I help you with?

Related Questions

Why use throw in java in compare try-catch?

we use throws in our program so that we dont need to write try & catch block & to avoid the exception


What is the use of try in java?

The try keyword is used in Java to handle problematic situations that are commonly known as "Exceptions" The try keyword is used in conjunction with the catch keyword. If any exception is thrown by code inside the try block, they will be caught and handled by the catch block. Ex: try { ... ... } catch (Exception e){ ... }


Why use catch keyword in java?

no, because catch is used to handle exceptions which are generated from try block


What is the use of catch block in java?

the catch block catches the exception from the try block to display a proper message about the exception. Answered by, SOORAJ.M.S


When should we use exception handling in java?

Exception handling should be used in Java in all cases where you as a programmer suspect that your code might throw some exceptions or create errors that might look ugly when a user is using the application. In such cases you use exception handling to catch and handle the exception and exit gracefully. You use the try - catch block in Java for exception handling.


How you do use finally keyword in java?

You use it in combination with "try" and "catch". Any commands after "finally" will be run whether there is an error or not. Cleanup commands are typically placed here.


How many catch blocks can you use with one try block in java?

Several - I don't believe there is a fixed limit. The idea is that, depending on the specific exception that occured, you carry out different actions.


When l try to use craftbukkit for minecraft it says that java is not recognized as an internal or external command?

If you don't have Java installed, download and install it. If you do have Java installed, try changing 'java' in the batch file to "C:\Program Files\Java\jre6\bin\java.exe" (with quotes) or wherever you have Java installed.


Why does the RuneScape website work but the game does not?

One thing you might try is to use a different browser. For example, if it doesn't work with FireFox, try Opera or Google Chrome. You may have a problem with the Java installation, so reinstalling Java for the browser may also help.One thing you might try is to use a different browser. For example, if it doesn't work with FireFox, try Opera or Google Chrome. You may have a problem with the Java installation, so reinstalling Java for the browser may also help.One thing you might try is to use a different browser. For example, if it doesn't work with FireFox, try Opera or Google Chrome. You may have a problem with the Java installation, so reinstalling Java for the browser may also help.One thing you might try is to use a different browser. For example, if it doesn't work with FireFox, try Opera or Google Chrome. You may have a problem with the Java installation, so reinstalling Java for the browser may also help.


Cannot get java to work on windows browser?

Sometimes you have to download Java from the relevant Web page. Sometimes it helps to use a different browser. For example, if you usually use FireFox, try Opera or Google Chrome instead.Sometimes you have to download Java from the relevant Web page. Sometimes it helps to use a different browser. For example, if you usually use FireFox, try Opera or Google Chrome instead.Sometimes you have to download Java from the relevant Web page. Sometimes it helps to use a different browser. For example, if you usually use FireFox, try Opera or Google Chrome instead.Sometimes you have to download Java from the relevant Web page. Sometimes it helps to use a different browser. For example, if you usually use FireFox, try Opera or Google Chrome instead.


What are some threats to the horseshoe crabs survival?

fisherman who try to catch horeshoe crabs and use them as bait!fisherman who try to catch horeshoe crabs and use them as bait!


What is the use of a finally clause?

Finally is used in exception blocks:try{...}catch(...){...}finally{...}Finally is used if you need to do something in case if an exception was occurred. And if it cannot be done in the catch block.