我想输出两个用逗号分隔的数字System.out.format.我试图用%来逃避它,但它没有帮助.
目标输出应采用(0.92,0.91)的形式
System.out.format("(%.2f% %.2f)%n", x, fx);
^--- I want to add a ',' character here
Run Code Online (Sandbox Code Playgroud)
您不必以格式转义逗号.只需在格式中放置一个逗号,旁边没有百分号.
System.out.format("(%.2f,%.2f)%n", x, fx);
Run Code Online (Sandbox Code Playgroud)