This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

double array to String

 
zoyu mi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic