I am returning a double array and it sometime contains endless decimals but i would like to end it after three decimal spaces. I have tried using DecimalFormat but will not work on array.
Any help appreciated
Printable View
I am returning a double array and it sometime contains endless decimals but i would like to end it after three decimal spaces. I have tried using DecimalFormat but will not work on array.
Any help appreciated
You need to apply the decimal format to each of the decimals that you intend representing with String instances.
o, hmm. I was trying to avoid that but if that is it then thanks.
You're welcome.
Doubles are doubles and Strings are Strings; and it's only the latter which have a base and therefore decimal places etc. Some langauges are quite casual about interchanging these types but Java isn't.
Also some languages provide a syntax for applying an operation to each of the elements of a collection like an array. But with Java you use a for loop for that.