File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes parseInt throwing exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "parseInt throwing exception" Watch "parseInt throwing exception" New topic

parseInt throwing exception

prav ba

Joined: Jun 17, 2007
Posts: 12
hi all,
am doing something really simple (at least looks simple to me) but i get a java.lang.NumberFormatException: For input string: "70611111111111111111111111111111111111"

all my code does it try and parse a string, does this error mean the integer value of the string passed in is too big ??

code: java.lang.Integer.parseInt(str);

Steve Luke

Joined: Jan 28, 2003
Posts: 4181

Yup, number is too big. You might try using instead.

Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46349
It's always worth looking in the API dopcumentation.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15081

An int in Java is 32 bits, and is stored in two's complement format.

Because of this, the largest positive value that you can store in an int is 2^31 - 1 = 2147483647

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: parseInt throwing exception
It's not a secret anymore!