?
Solved

Integer.parseString throws java.lang.NumberFormatException

Posted on 2004-09-14
1
Medium Priority
?
1,811 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
KeithWatson earned 500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
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 fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

650 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