提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
测试数学类方法
public class Main { /** 来 自 NowJava.com - 时 代 Java **/ public static void main(String[] args) { System.out.printf("Math.abs(23.7) = %f%n", Math.abs(23.7)); System.out.printf("Math.abs(0.0) = %f%n", Math.abs(0.0)); System.out.printf("Math.abs(-23.7) = %f%n", Math.abs(-23.7)); System.out.printf("Math.ceil(9.2) = %f%n", Math.ceil(9.2)); System.out.printf("Math.ceil(-9.8) = %f%n", Math.ceil(-9.8)); System.out.printf("Math.cos(0.0) = %f%n", Math.cos(0.0)); System.out.printf("Math.exp(1.0) = %f%n", Math.exp(1.0)); System.out.printf("Math.exp(2.0) = %f%n", Math.exp(2.0)); System.out.printf("Math.floor(9.2) = %f%n", Math.floor(9.2)); System.out.printf("Math.floor(-9.8) = %f%n", Math.floor(-9.8)); System.out.printf("Math.log(Math.E) = %f%n", Math.log(Math.E)); /* 时代Java - nowjava.com 提供 */ System.out.printf("Math.log(Math.E * Math.E) = %f%n", Math.log(Math.E * Math.E)); System.out.printf("Math.max(2.3, 12.7) = %f%n", Math.max(2.3, 12.7)); System.out.printf("Math.max(-2.3, -12.7) = %f%n", Math.max(-2.3, -12.7)); System.out.printf("Math.min(2.3, 12.7) = %f%n", Math.min(2.3, 12.7)); System.out.printf("Math.min(-2.3, -12.7) = %f%n", Math.min(-2.3, -12.7)); System.out.printf("Math.pow(2.0, 7.0) = %f%n", Math.pow(2.0, 7.0)); System.out.printf(