Date日期类 Date表示特定的时间,精确到毫秒; 构造方法: public Data() public Date(long date) 常用方法: public long getTime() public void setTime(long time) public Boolean before(Date when) public Boolean after(Date when) public int compareTo(Date anotherDate) public String toS…
一.Math类 Math类中有一些常用的数学函数,比较简单,不进行详细解释,仅举例说明: 1.绝对值和取整 import java.lang.Math; public class Mat { public static void main(String []args) { //abs()返回绝对值 System.out.println(Math.abs(-2.5)); //ceil()返回较大的整数 System.out.println(Math.ceil(-2.6)); System.out.…
Math类的random()方法 Math类的random()方法可以生成大于等于0.0.小于1.0的double型随机数. Math.random()方法语句基础上处理可获得多种类型.或任意范围的随机数. 公式: int num=(int)(Math.random()*n); //返回大于等于0小于n之间的随机数 int num0=m+(int)(Matn.randon()*n); //返回大于等于m小于m+n(不包括m+n)之间的随机数…