Solved

Integer.parseString throws java.lang.NumberFormatException

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this post we will learn different types of Android Layout and some basics of an Android App.
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…
Starting up a Project

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