How to Convert Double to String to Double in Java?


Java lang package provides a Double class which has methods to convert Double to String and vice versa. You can convert a String to a double using the parseDouble() method and double to String using the toString() method

Example

Live Demo

public class StringDouble {
   public static void main(String args[]){
      Double data1 = 2.2;
      String str = Double.toString(data1);
      System.out.println(str);
      Double data2 = Double.parseDouble(str);
      System.out.println(data2);
   }
}

Output

2.2
2.2

Updated on: 26-Feb-2020

178 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements