常用类2,system,包装类

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.方法:

  1. Integer.toHexString() 十六进制
  2. Integer.toOctalString() 八进制
  3. Integer.toBinaryString() 二进制
  4. Integer.toString(数字,进制); 转成字符串

2.自动装箱拆箱

基本类型和引用类直接运算

3.数据类型转换

  1. int a =Integer.parseInt(“23”)
  2. double b = Double.parseDouble(“3.45”)
  3. 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值