answersLogoWhite

0

public int getValue(String value){

int i;

try {

i = Integer.parseInt(value)

} catch (Exception e){

i = 0;

}

return i;

}

User Avatar

Wiki User

16y 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 happens if the static modifier is removed from the signature of the main program in java?

Actually speaking nothing major happens. That method would become just another method in the class. You cannot use that as the method to begin the program execution in your class. Your class will not be a standalone java program and you cannot execute it like you did before using the public static void main() method.


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!


In what state is it illegal to use a lasso to catch a fish?

It is illegal to use a lasso to catch a fish in Washington state. The use of a lasso or similar method to catch fish is prohibited under Washington's fishing regulations.


Can you catch Zapdos in one try?

Use a master ball on it.


Can you catch hoho in Pokemon heartgold if you defeated him the first time?

if you use the action replay rebattle code you can try to battle it again or try to catch it


Catch mew Pokemon Yellow?

You use the master-ball on it, try to weaken it first as this will make it esier to catch.


How do you write a java program to find the square root of a number?

You can use the Math.sqrt() method.


How do you use rerun in a sentence?

Let's try to rerun the program.


Why use catch keyword in java?

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


To convert strings to double?

Use the Double.parseDouble(String val) function. Remember to surround it by a try catch block to ensure that any invalid input valules to the method would not cause your application to hang out with an exeption.


How do you repair an unhandled exception?

You can stop an unhandled exception by handling it. When your program crashes it will tell you exactly where it crashed and what exception it ran into. Dealing with the exception is the hard part. Generally, you want to take one of two approaches. The first is to make sure that the exception cannot happen. You may, for example, have to validate data to make sure that your users aren't allowed to give input which would result in a division-by-zero exception. The second is to allow the exception to be thrown, but use a try-catch block to catch it and print out a useful message instead of crashing. The method you choose will depend on what your program is supposed to do, who is using it, what exceptions are being thrown, where they're being thrown, etc. There's no silver bullet solution for handling an exception.