1 Packagedemo04;2 3 //all methods of the math class are static methods, and direct class names are called4 Public classMathdemo {5 Public Static voidMain (string[] args) {6 7 //static int abs (int a) returns the absolute value of int8System.out.println (Math.Abs (-1));//19 Ten //static Double Ceil (double A) rounding up OneSystem.out.println (Math.ceil (5.1));//6.0 A - //static double floor (double a) rounding down -System.out.println (Math.floor (5.1));//5.0 the - //static Double pow (double A, double b) A's B-square -System.out.println (Math.pow (2, 3));//8.0 - + //static double sqrt (double A) -System.out.println (MATH.SQRT (4));//2.0 + A //static double random () number [0.0,1.0] at System.out.println (Math.random ()); - - //Static Long round (double a) rounded rounding -System.out.println (Math.Round (1.5));//2 - - } in } -
Java Math Class