1 Public classDemo1_math {2 3 /*4 * The Math class contains methods for performing basic mathematical operations, such as: exponential, logarithmic, square root, etc.5 * All methods in math are static, and construction methods are private6 * public static int abs (int a) to find the absolute value of a number7 * public static double ceil (double A) rounding up, returning a double value8 * public static double floor (double b) rounded down, returning a double value9 * public static int max (int a, int b) takes a large value of two and Min is similar to Max, taking the minimum valueTen * public static int pow (double A, double b) to power a double value One * public static double random () takes a [0.0,1.0] between a double A * public static int round (float a) rounding - * public static double sqrt (double a) open square for a double number - */ the Public Static voidMain (string[] args) { -System.out.println (Math.Abs (-10)); -System.out.println (Math.ceil (12.7)); -System.out.println (Math.floor (12.6)); +System.out.println (Math.max (1, 9)); -System.out.println (Math.pow (6.0, 2.0)); + System.out.println (Math.random ()); ASystem.out.println (Math.Round (3.15)); atSystem.out.println (MATH.SQRT (9)); - /* - * Operation results are as follows: - * Ten - 13.0 - 12.0 in 9 - 36.0 to 0.2989099810206127 + 3 - 3.0 the */ * } $}
Java's math class