my dog learned polymorphism
The moose likes Beginning Java and the fly likes double array to String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "double array to String" Watch "double array to String" New topic

double array to String

zoyu mi

Joined: Mar 29, 2013
Posts: 3
I need to use the toString() method but I dont how to chance an array of double primitive type into a string of only the values of the array.
Help please. Very confused
Jeff Verdegan

Joined: Jan 03, 2004
Posts: 6109

Arrays don't override the toString() method. So if you want to print the contents of an array, you have to iterate over the array and add each element to a StringBuilder (or just print them as you go). Or you can use java.util.Arrays.toString() for 1D arrays and Arrays.deepToString() for multi-dimensional arrays (which are really just arrays of arrays in Java).
I agree. Here's the link:
subject: double array to String
It's not a secret anymore!