package test;
public class PointDemo {
public static void main(String[] args) {
String s1 = "1.00000";
if (s1.indexOf(".") > 0) {
// 正则表达
s1 = s1.replaceAll("0+?$", "");// 去掉后面无用的零
s1 = s1.replaceAll("[.]$", "");// 如小数点后面全是零则去掉小数点,这两个顺序不要颠倒
}
System.out.println(s1);// 输出1
}
}
去掉小数点后的0
最新推荐文章于 2024-05-11 00:01:05 发布