> For the complete documentation index, see [llms.txt](https://xiaoxiami.gitbook.io/java/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xiaoxiami.gitbook.io/java/javaji-chu/chang-yong-lei/shu-xue-lei.md).

# 数学类

概述：提供科学计算的一些方法。

示例：

```java
package com.itcode.demo4;  


import java.text.DateFormat;  
import java.text.ParseException;  
import java.text.SimpleDateFormat;  
import java.util.Date;  
import java.util.Random;  

/** 
 * @Auther: 成都码到功成学员 
 * @Description: 
 * Math类 
 */  
public class TestMath {  
    public static void main(String[] args) throws ParseException {  
        //向上取整  
        System.out.println(Math.ceil(5.3));  
        //向下取整  
        System.out.println(Math.floor(5.3));  
        // 四舍五入  
        System.out.println(Math.round(5.3));  
        System.out.println(Math.round(5.6));  
        //绝对值  
        System.out.println(Math.abs(-54));  
        //平方根、a的b次幂等操作  
        System.out.println(Math.sqrt(64));  
        //i的j次方  
        System.out.println(Math.pow(3, 4));  
        //关于3.14  
        System.out.println(Math.PI);  
        // 随机数[0,1)  
        System.out.println(Math.random());  
        // 随机生成10-25的随机数  
        System.out.println(10+new Random().nextInt(15));  
    }  
}
```

效果：

![](https://3884904792-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfnT30K7z1iNbyIaGVh%2F-LxVH-DsB4y0lJ8xCby5%2F-LxVIzO9uBc3qtaLWZb-%2Fimage.png?alt=media\&token=0ee8ad8e-4f31-4150-827b-0fe67cc395b8)
