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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started