Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Using Integer.parseInt

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Using Integer.parseInt

    Hi there, im having problem converting my string to integer..

    Basically my program is a dispenser that holds items, there price and quantity I can manipulate these through txtbox's which are defined as arrays and then i show them using a txtarea.

    My currently problem is that im wanting to show the price of my items through the txt area I can display my items names as follows
    for(int i =0; i<myDispenser.length; i++){
    			String itemName = txtadditem[i].getText();
    I then call my items names;
     
    output = output + "  Product Name "+ ":" +  myDispenser[i].getItemName();
    For my items price which are currently declared as int I am trying to do the following
    String Price = txtprice[i].getText();
    			itemPrice = Integer.parseInt(Price);
    however I get this error
    Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: ""
    at java.lang.NumberFormatException.forInputString(Unk nown Source)
    at java.lang.Integer.parseInt(Unknown Source)
    at java.lang.Integer.parseInt(Unknown Source)

    I've been trying for several days and still cant see my problem any help would be appreciated if my code that I have displayed is insufficient please say so..

    Many thanks
    Last edited by Fraz; April 5th, 2010 at 07:20 AM.

  2. Default Related threads:


  3. #2
    Junior Member
    Join Date
    Apr 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Using Integer.parseInt

    nevermind I have solved the problem I used a try/catch

Similar Threads

  1. How to fetch integer data from excel
    By nehakuls in forum JDBC & Databases
    Replies: 5
    Last Post: May 14th, 2010, 01:44 AM
  2. Hex to Integer Problem
    By TempSpectre in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 1st, 2010, 06:01 AM
  3. int and Integer
    By chronoz13 in forum Java Theory & Questions
    Replies: 5
    Last Post: December 31st, 2009, 03:20 AM
  4. check if a number is an integer
    By rsala004 in forum Java Theory & Questions
    Replies: 3
    Last Post: August 15th, 2009, 03:51 PM
  5. [SOLVED] How to make a integer negative if it meets a certain criteria?
    By Lizard in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 14th, 2009, 02:27 PM