Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to convert string to number?

 
Mr Tan Ah Seng
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need help.

I use Integer.parseInt to convert string in integer format(example 123) to integer number without problem.

However, I have problem using Integer.parseInt to convert a string in float number format(example 1.23) to float number, so that I can use it for calculation.

Thanks.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12087
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can't use Integer.parseInt to get a float - it returns an int!!!

but i bet you COULD use Float.parseFloat...
 
Mr Tan Ah Seng
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I can do it now.
Thanks for your help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic