Privacy Policy Terms Of Use. Copyright © 2006-2010 Java Tutorials and Examples.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
- /*
- * Convert String to Double example. Program to convert Java
- * String object to Double object.
- */
- public class StringToDouble {
- public static void main(String args[]){
- //new String object
- String str = new String("16.85");
- //Use Double(String) constructor
- Double dObj1 = new Double(str);
- //OR Use static valueOf(String) method of Double class
- Double bObj2 = Double.valueOf(str); //throws NumberFormatException
- System.out.println("String converted to Double: " + dObj1);
- }
- }

Post new comment