Solved

Integer.parseString throws java.lang.NumberFormatException

Posted on 2004-09-14
1
1,794 Views
Last Modified: 2008-03-06
Want to know why I get the above error in the following program for string s2. The string s1 and s2 are hex strings.

public class sample1{
public static void main(String args[])
     {
       String s1 = "6666B5C2";
       String s2 = "85EB3EC2";

       int val1 = Integer.parseInt(s1,16);
       System.out.println("The value for s1 is : " + val1);

       int val2 = Integer.parseInt(s2,16);
       System.out.println("The value for s2 is : " + val2);
     }
}

Thanks,
PK
0
Comment
Question by:pkhanna01
1 Comment
 
LVL 3

Accepted Solution

by:
KeithWatson earned 125 total points
ID: 12060744
The second number in decimal is 2,246,786,754, which is just too big to fit into a 32 bit signed int. It will need to be a maximum of 2,147,483,647 to fit.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
fix34  challenge 9 97
Batch file output 20 77
endX challenge 2 50
oracle query help 18 78
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now