[Solved] Print command output [closed]


If you consult the documentation for printf in C and System.out.println in Java, you will see that they format output in different ways. This is because they are totally different, and I’m not sure why you expected them to produce the same results.

If you want printf-style formatting in Java, consider using String.format() to format the output, or using System.out.printf(), which still may require explicit formatting widths to be identical to the default behavior of printf in C (which is 6 decimal places if not explicitly specified, hence your 8.000000).

solved Print command output [closed]