How to convert a Double array to a String array in java?

Java 8Object Oriented ProgrammingProgramming

You can convert a double array to a string using the toString() method. To convert a double array to a string array, convert each element of it to string and populate the String array with them.

Example

Live Demo

import java.util.Arrays;

public class DoubleArrayToString {
   public static void main(String args[]) {
      Double[] arr = {12.4, 35.2, 25.6, 98.7, 56.4};
      int size = arr.length;
      String[] str = new String[size];
   
      for(int i=0; i<size; i++) {
         str[i] = arr[i].toString();
         System.out.println(str[i]);
      }
   }
}

Output

12.4
35.2
25.6
98.7
56.4
raja
Published on 09-Jan-2018 11:45:28
Advertisements