File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to convert string to number? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to convert string to number?" Watch "How to convert string to number?" New topic
Author

How to convert string to number?

Mr Tan Ah Seng
Greenhorn

Joined: Sep 20, 2004
Posts: 2
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

Joined: Oct 02, 2003
Posts: 11560
    
  17

you can't use Integer.parseInt to get a float - it returns an int!!!

but i bet you COULD use Float.parseFloat...


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Mr Tan Ah Seng
Greenhorn

Joined: Sep 20, 2004
Posts: 2
Yes, I can do it now.
Thanks for your help.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to convert string to number?