在Java中使用2个小数位打印整数


问题内容

在我的代码中,我使用整数乘以100作为小数(0.1为10等)。您能帮我格式化输出以显示为十进制吗?


问题答案:
int x = 100;
DecimalFormat df = new DecimalFormat("#.00"); // Set your desired format here.
System.out.println(df.format(x/100.0));