System类
System类代表系统,系统级的很多属性和控制方法都放置在该类的内部。该类位于java.lang包。
由于该类的构造方法是private的,所以无法创建该类的对象,也就是无法实例化该类。其内部的成员变量和成员方法都是static的。
- System类常用方法
-
exit 退出当前程序
-
arrays.copyOf 完成复制数组
-
currentTimeMillens 返回当前时间距离1970-1-1的毫秒数
System.currentTimeMillens(); //返回当前时间戳
-
gc 运行垃圾回收机制
System.gc();
-
BigInteger 和 BigDecimal
应用场景:
- BigInteger 适合保存比较大的整形
- BigDcimal 适合保存精度更高的浮点型(小数)
-
BigInteger
//在对BIgInteger 进行加减乘除时要使用对应的方法 //1) add 加 2) subtract减 3)multiply乘 4) divide除 BigInteger bigInteger = new BigInteger("29999999999999998888");
-
BigDecimal
//在对BigDecimal 进行加减乘除时也要使用对应的方法 //1) add 加 2) subtract减 3)multiply乘 4) divide除 BigDecimal bigDecimal = new BigDecimal("123.456662126125125152152");