1

I have been trying to convert a double array to a string where numbers are separated with a space.

public class StringTest {

    public static void main(String[] args) {

        double[] g =  {1.2,1.4,1.4} ;
        String d = StringUtils.join(g, " ");
        System.out.println(d);
    }
}

Commons Lang javadoc tells me that it is possible to do this, code runs as well but I get only [D@54a50a00 printed out. What is missing here?

Tiny
  • 27,221
  • 105
  • 339
  • 599
zamk
  • 71
  • 3
  • 14

1 Answers1

5

You are currently using StringUtils#join(T...). You seem to want to use StringUtils#join(double[], char). Simply change your " " to a ' '.

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724