Try...Catch


[ Follow Ups ] [ Post Followup ] [ WWWBoard for 308-203A ] [ FAQ ]

Posted by Philippe Benoit on September 12, 19100 at 21:49:06:

I have a question..

Lets say you want to use try..catch to pinpoint the error when someone enter a letter instead of an integer.
I use
try {
int number = Integer.parseInt(StdIn.readLine());
}
catch(NumberFormatException)...

yet when I compile it does not seem to aknowledge my int number.
Can we use try-catch only with method calls??
ex:
try{
liver.spleen();
}....


Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ WWWBoard for 308-203A ] [ FAQ ]