package com.javaWave.blogSpot;
public class String2double {
/**
* @param args
*/
public static void main(String[] args) {
// String myString = "javaWave"; // do this if you want an exception
String myString = "100.00";
try {
double convertedValue =
Double.valueOf(myString.trim()).doubleValue();
System.out.println("convertedValue = " + convertedValue);
} catch (NumberFormatException nfe) {
System.out.println("NumberFormatException: "
+ nfe.getMessage());
}
}
}
javawaveblogs-20
Tuesday, December 2, 2008
Converting Java String to double
The following code will convert Java String into double data type.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment