String.format();常用两个方法
String.format("%.2f",x):保留两位小数,注意此处x不能是int类型,要是小数才行。
String.format("%03d", x):总共三位,不足的在x前面补0,如果x超过三位,不变。
详细用法请看:https://blog.csdn.net/anita9999/article/details/82346552
String.format()方法
最新推荐文章于 2023-12-27 10:59:27 发布
String.format();常用两个方法
String.format("%.2f",x):保留两位小数,注意此处x不能是int类型,要是小数才行。
String.format("%03d", x):总共三位,不足的在x前面补0,如果x超过三位,不变。
详细用法请看:https://blog.csdn.net/anita9999/article/details/82346552