因为Java自带的Math库里只有四舍五入的函数,所以我们需要自己自定义一个
class MathUtil{
private MathUtil(){}
public static double round (double num, int scale){
return Math.round(num * Math.pow(10, scale)) / Math.pow(10, scale);
}
}
二 正则表达式判断验证email邮件
public class ZhengZeDemo {
public static void main(String[] args) {
String str = "java5201314@qq.com";// 要判断的数据
String regex = "[a-zA-Z0-9]\w+@\w+\.(cn|com|com.cn|net|gov)"; // 正则表达式
System.out.println(str.matches(regex));
}
}



