1.基本类型包装类
注意:1个字节内的数指向同个对象 ,例如定义integer为100。
包装类:数字继承自number类(包括大数,但是字符,布尔不是)
1.概述
char Character
int Integer
byte Byte
short Short
long Long
float Float
double Double
boolean Boolean
2.Integer类
1.方法:
- Integer.toHexString() 十六进制
- Integer.toOctalString() 八进制
- Integer.toBinaryString() 二进制
- Integer.toString(数字,进制); 转成字符串
2.自动装箱拆箱
基本类型和引用类直接运算
3.数据类型转换
- int a =Integer.parseInt(“23”)
- double b = Double.parseDouble(“3.45”)
- String value1 = Integer.toString(12);
2.System类
1.currentTimeMillis
long start = System.currentTimeMillis();//当前时间x-1970年1月1日零时零分零秒
2.exit
System.exit(0) 退出虚拟机,所有程序全停止
3.gc
System.gc(); 调用回收对象所属类的finalize方法()
4.arraycopy
arraycopy(Object src, int srcPos, Object dest, int destPos, int length)
Object src, 要复制的源数组
int srcPos, 数组源的起始索引
Object dest,复制后的目标数组
int destPos,目标数组起始索引
int length, 复制几个
3.Math类
1.sqrt
static double sqrt(double d)
返回参数的平方根
2. pow
static double pow(double a, double b)
a的b次方
3.random()
Math.random(); 返回随机数 0.0-1.0之间
4.大数据运算
BigInteger
构造方法1 publuc BigInteger("string字符串");
构造方法2 publuc BigInteger("进制","string字符串");
public BigInteger add(BigInteger val):做加法运算
public BigInteger subtract(BigInteger val):做减法运算
public BigInteger multiply(BigInteger val):做乘法运算
public BigInteger divide(BigInteger val):做除法运算
public BigInteger remainder(BigInteger val):做取余操作
public BigInteger pow(int exponet):进行取参数的 exponet 次方操作
public BigInteger negate():取相反数
public BigInteger shiftLegt(int n):将数字左移 n 位,如果 n 为负数,做右移操作
public BigInteger shiftRight(int n):将数字右移 n 位,如果 n 为负数,做左移操作
public int compareTo(BigInteger val):做数字比较操作
public BigInteger max(BigInteger val):返回较大的数值
BigDecimal
divide(BigInteger2, scale(精度), BigDecimal.**ROUND_HALF_UP**(取舍方式))
.doubleValue();返回double