Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6057129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:27:15+00:00 2026-05-23T08:27:15+00:00

I have this problem converting object into string… I make use of the toString()

  • 0

I have this problem converting object into string… I make use of the toString() function… and since the conversion of object into string were inside the try{}catch(exception e){}, i keep on receiving an output error: For input string: ""

What should be the problem if i keep on receiving an error message like that?

More elaboration:

  1. the Object came from a jComboBox
    which consists of items from a
    database.
  2. I am using a JFrame Form instead of
    a Java Class.

All i want to do is to capture the selected Item from the JComboBox which happens to be an object. And then after capturing it. I’ll use the value for my query in the database.

Here’s my code(partial):

private void SUBMITActionPerformed(java.awt.event.ActionEvent evt) {                                       
    try {
        Class.forName(Connect.DRIVER);
        Connection con = DriverManager.getConnection(Connect.CONNECTION_STRING,
                Connect.USERNAME, Connect.PASSWORD);

        Object obj = jComboBox1.getSelectedItem();
        String item_name = obj.toString();

        int month = jMonthChooser.getMonth();
        int q_box = Integer.parseInt(quantity_box_txtbox.getText());
        double unit_price_box = 0;
        int q_pc = Integer.parseInt(quantity_pc_txtbox.getText());
        double unit_price_pc = 0;
        double sub_total_box = 0;
        double sub_total_pc = 0;
        double grand_total = 0;

        //Testing
        System.out.println(jMonthChooser.getMonth());
        System.out.println(item_name);

    } catch (Exception e) {
        System.out.println("Error: "+e.getMessage());
    }
}           

If you have anything you don’t understand regarding with the way I explain my question please tell me… i’ll try my best to elaborate further.

Thanks in advance.

🙂

here’s the complete error:

Error: java.lang.NumberFormatException : For input string: ""
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:27:15+00:00Added an answer on May 23, 2026 at 8:27 am

    Well, to start with:

    • Don’t catch just Exception; catch specific subclasses
    • Don’t just catch the exception; you almost certainly want to propagate it up to the caller
    • Don’t log just the message – log the whole exception, including the stack trace and exception type.

    The exception looks like it’s trying to parse a string – not trying to convert an object to a string. I strongly suspect that the problem is one of these lines:

    int q_box = Integer.parseInt(quantity_box_txtbox.getText());
    int q_pc = Integer.parseInt(quantity_pc_txtbox.getText());
    

    My guess is that one of the textboxes is empty – so you’re effectively calling Integer.parseInt("") which is failing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this problem decomposing a relation schema into a set of schemas that
I code this function which converts all pipes into commas, and after that converting
I am having this trouble in converting the exiting time string into a new
I have run in to this problem of converting a C++/CLI pointer to a
I have this problem I'm hoping someone knows the answer to. I have an
I have this problem where I open Visual Studio and the internal windows are
i have this problem to find a particular xml node l have post this
I have this problem I've been trying to tackle for a while. I have
i have this problem: ms-access could not delete and i found a potential solution
I have this problem in my ASP.NET application where I'm seeing some of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.