• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem to print variable in toString funtion  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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: 56610
172
  • Mark post as helpful
  • send pies
  • 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
  • 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().
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!