A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

© aguang 中级黑马   /  2015-8-24 08:39  /  171 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

  1. package test;

  2. /*
  3. *Math:数学运算
  4. * 成员变量
  5. * PI  E
  6. *
  7. * 成员方法
  8. *                 public static int abs(int a) 绝对值
  9. *                 public static double ceil(double a)  向上取整
  10. *                 public static double floor(double a) 向下取整
  11. *                 public static  int max(int a,int b)
  12. *                 public static int min (int a,int b)
  13. *                 public static double pow(double a,double b)  a的b次幂
  14. *                 public static double random(); [0.0-1.0)
  15. *                 public static int round(float)  参数为double   四舍五入
  16. *                 public static double sqrt(double a)  正平方根
  17. *                
  18. * */

  19. public class Test01 {
  20.         public static void main(String[] args) {
  21.                 System.out.println(Math.PI);
  22.                 System.out.println(Math.E);
  23.                
  24.                 //abs
  25.                 System.out.println(Math.abs(-10));
  26.                 //ceil
  27.                 System.out.println(Math.ceil(12.34));
  28.                 //floor
  29.                 System.out.println(Math.floor(12.34));
  30.                 //max
  31.                 System.out.println(Math.max(12,33));
  32.                 System.out.println(Math.max(12, Math.max(14, 44))); //方法嵌套调用
  33.                 //pow
  34.                 System.out.println(Math.pow(2,3));
  35.                 //round
  36.                 System.out.println(Math.round(12.63));
  37.                 System.out.println(Math.round(12.11));
  38.                 //sqrt
  39.                 System.out.println(Math.sqrt(4));
  40.         }
  41. }


























复制代码

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马