Program to Convert double to String in Java
Below is the implementation of double to String conversion using ‘+’ :
Java
// Java Program to Convert // Double to String Using '+' import java.io.*; // Driver Class class GFG { // main function public static void main(String[] args) { // Double declared double num = 12.345 ; // Converting Double to String String str = num + "" ; System.out.println(str); // Type of num System.out.println( "Type of num : " + ((Object)num).getClass().getSimpleName()); // Converted element to string System.out.println( "Type of str : " + ((Object)str).getClass().getSimpleName()); } } |
12.345 Type of num : Double Type of str : String
Explaination of the above Program:
In above program we are converting num(Double) to String using ‘+’ Operator.
Java Program to Convert Double to String
The primary goal of double to String conversion in Java is to store big streams of numbers that are coming where even data types fail to store the stream of numbers. It is generically carried out when we want to display the bigger values. In this article, we will learn How to Convert double to String in Java.