1、常用数学函数:
注:如果在源文件顶部静态导入Math类下所有方法(import static java.lang.Math.*;),那么,就不必在数学方法名和常量名前添加前缀:Math
在Math类中,为了达到最快的性能,所有的方法都使用计算机浮点单元中的例程
int Math.round(float),long Math.round(double) 四舍五入
[注:round()底层可以理解为floor(a+0.5),eg:Math.round(11.5)等价于(int)Math.floor(11.5+0.5)==12,Math.round(-11.5)等价于(int)Math.floor(-11.5+0.5)==-11]
float Math.abs(float),double Math.abs(double),int Math.abs(int),long Math.abs(long) 取绝对值
double Math.exp(double) 指数函数
double Math.log(double) 自然对数
double Math.log10(double) 以10为底的对数
int max(int,int); 最大值
int min(int,int) 最小值
Math.PI 常量π的近似值,double类型,精确到小数点后15位
Math.E 常量e的近似值,double类型,精确到小数点后15位
关于double ceil(double),double floor(double):
关于随机数:
double Math.random() 范围:[0,1) 生成[1,10]随机数:Math.round(Math.random()*10)
Random rand=new Random() 生成[low,high]随机数:rand.next(high-low+1)+low
2、System.exit(0); 终止程序
3、类型转换函数
String->int :Integer.valueOf(" "); 该函数返回Integer对象 Integer.praseInt(" ");返回int类型数据
int->String:String.valueOf(); Integer.toString();
char->String:String.valueOf(' ');
5、