Solved

Integer.parseString throws java.lang.NumberFormatException

Posted on 2004-09-14
1
1,806 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 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

739 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