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


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

Sharon Christine
Sharon Christine

An investment in knowledge pays the best interest

Updated on: 19-Feb-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements