String.format的测试

String result1 = String.format("小明今年%d岁,他住在%s,他的月工资有%.2f", 25,"北京市",6633.435);
System.out.println(result1);//输出:小明今年25岁,他住在北京市,他的月工资有6633.44
/*****************************************************/
double num = 123.4567899;
String result2 = String.format("%e", num);
System.out.println(result2);//输出:1.234568e+02

猜你喜欢

转载自blog.csdn.net/rocling/article/details/81783945