Wrapper classes Topic: JavaLanguage
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Thursday, June 8, 2006 08:48 AM

When i try to run this program i don't get any output?
Why?


class Simple
{
public static void main(String[] args)
{

String a="45";
try
{
a=a.concat(".05");
int s =(int)Integer.parseInt(a);
System.out.println(s);
}
catch(Exception e)
{
}

}
}

Re: Wrapper classes Topic: JavaLanguage

Posted By:   WarnerJan_Veldhuis  
Posted On:   Thursday, June 8, 2006 03:18 PM

Repeat after me:
I WILL NEVER EVER HAVE AN EMPTY CATCH BLOCK AGAIN!

Re: Wrapper classes Topic: JavaLanguage

Posted By:   Simon_Ablett  
Posted On:   Thursday, June 8, 2006 09:40 AM

Because you are getting a NumberFormatException thrown in your call to parseInt. '45.05' is not an integer value. If you placed some diagnostic output in your catch statement you would have seen this.

Regards.
About | Sitemap | Contact