0%
Math类的常用方法
Math类都是静态的方法我们只需要直接使用即可
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| package Learn;
public class Test { public static void main(String[] args) { double num=-9.2; System.out.println(Math.abs(num)); System.out.println(Math.pow(num,2)); System.out.println(Math.ceil(num)); System.out.println(Math.floor(num)); System.out.println(Math.round(num)); System.out.println(Math.sqrt(9)); System.out.println(Math.round(Math.random()*5+2)); System.out.println((int)(Math.random()*6+2));
} }
|