Question: Java - I would like to know how to print a formatted 1d array that is made up of type double. I want to limit

Java - I would like to know how to print a formatted 1d array that is made up of type double.

I want to limit three digits to be printed after the decimal.

When I use this command: Arrays.toString(cmyk)

My results are: [0.33333333333333337, 4.0, 0.7333333333333334, 0.7058823529411764]

I want my results to look like this: [0.333, 4.000, 0.733, 0.705]

Is there another command I can add to the code Arrays.toString(cmyk) to print the array in the formt I need?

Also Arrays.toString(cmyk) prints an array with new values each time it's called, so I want all the different sets to have the same format. Thanks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!