FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 272   



There are two ways you can convert a String into double in Java

  1. Using Double.parseDouble(String input) - This returns primitive double
    String input = "12345.67";
    double output = Double.parseDouble(input);
    System.out.println(output);
    
  2. Using Double.valueOf(String input) - This returns instance of Double type
    String input = "12345.67";
    Double output = Double.valueOf(input);
    System.out.println(output);
    
    Note: Code will through NumberFormatException if you do not pass a valid double String.
    Ex. if you pass "foo" that causes NumberFormatException.



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News