The moose likes Beginning Java and the fly likes string to number Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "string to number" Watch "string to number" New topic

string to number

ngoc thai

Joined: Sep 08, 2001
Posts: 2
Dear JR members,
What is the best way to convert a string of digits to either an integer, float or double? Please advice.
Here are the two sample strings: "28769", "78.14159"
BJ Grau
Ranch Hand

Joined: Jul 10, 2001
Posts: 234
For the float, use the static method Float.parseFloat(String s)
for the int, use the static method Integer.parseInt(String s)
Each primitive wrapper class has a method like this.
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Ngoc,
To format the float or double values you can use:
I agree. Here's the link: http://aspose.com/file-tools
subject: string to number
Similar Threads
Tech Word Game
date format with MS Access database
ResultSet to Array
WA #1.....word association
How to convert byte array into string array?