• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem to print variable in toString funtion

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Word!!!

I have being developing an application were the user introduce information in a jcomboBox (main program using GUI). I use a second program to read and get item set. Them I put that information in one aray...

Most of the information are numbers and I need to do a mathematical operation with that numbers... But went I want to print that number in toString is no showing the result..

So this is the question...

What are the options to print number in toString function???

 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Integer#toString or String#valueOf??
Not sure I understand the question any more than that. You might do better to add Number class instances to the combo box, so each element represents a number directly rather than a String.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

yessica barria wrote:
What are the options to print number in toString function???



The toString() method is not mean to print anything. You can certainly make it do so, but that would be poor form. The toString() method is only for generating (or retreiving) the String representation. To print it out, you would use something like System.out.println().
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic