提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用数学课程中的数学方法
/** 来 自 时 代 J a v a 公 众 号 - nowjava.com **/ public class MathFunctionsApp { public static void main(String[] args) { int a = 100; int b = -50; int c = 3; double x = 25.0; double y = 3.0; double z = 4.0; System.out.println("abs(b) = " + Math.abs(b)); System.out.println("cbrt(x) = " + Math.cbrt(x));/** nowjava.com - 时代Java 提 供 **/ System.out.println("exp(y) = " + Math.exp(z)); System.out.println("hypot(y,z)= " + Math.hypot(y,z)); System.out.println("log(y) = " + Math.log(y)); System.out.println("log10(y) = " + Math.log10(y)); System.out.println("max(a, b) = " + Math.max(a, b)); System.out.println("min(a, b) = " + Math.min(a, b)); System.out.println("pow(a, c) = " + Math.pow(a, c)); System.out.println(