数字类
- Math类
-求随机数 - Handom类
-求随机数 - BigInteger类
-由于Integer用的多,大多数时候数字不会超过Integer类的范围,但是有时候如果超过了就用BigInteger类;不用计算的时候可以使用Long类型; - BigDecimal类
-运算的时候float类型和double类型常常丢失精度,为了更加精确的表示,计算浮点数用这个类;
日期类
Date:大多过期
Calender:
DateFormat dateFormat = new SimpleDateFormat( "yyyy年MM月dd日 HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY,0);
String yesterday = dateFormat.format(calendar.getTime());
System.out.println(yesterday);
// 使用增强for:遍历数组
for(int num: arr) {
System.out.println(num++);
}