Exception in thread “main” java.lang.NumberFormatException

Posted: May 9, 2012 in Java

Number Format Exception

 It is child class of illegalArgumentException and it is unchecked.

It is thrown programmatically to indicate that the application has attempted to convert a string to number but the string is not format properly


public static void main(String[] args) {

      Integer integer = new Integer(“10”);


      Integer integer2 = new Integer(“ten”); —–> string to number but the string is  not format properly.                     





Exception in thread “main” java.lang.NumberFormatException: For input string: “ten”

      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)

      at java.lang.Integer.parseInt(Integer.java:447)

      at java.lang.Integer.<init>(Integer.java:620)

            at com.clarity.test1.main(test1.java:97)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s