File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why am i getting NumberFormatException

 
ashwin bhawsar
Ranch Hand
Posts: 62
Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried out the following :

int a=Integer.parseInt("11",2);
System.out.print(a); // output 3

int b=Integer.parseInt("015",8);
System.out.print(b);// output 13

int c=Integer.parseInt("0xf", 16); // NumberFormatException


I did not get why i am getting the exception.
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the documentation:
Parses the string argument as a signed integer in the radix specified by the second argument. The characters in the string must all be digits of the specified radix (as determined by whether Character.digit(char, int) returns a nonnegative value), except that the first character may be an ASCII minus sign '-' ('\u002D') to indicate a negative value.


So you want

 
ashwin bhawsar
Ranch Hand
Posts: 62
Eclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ohh, thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic