MathSystem
生活随笔
收集整理的這篇文章主要介紹了
MathSystem
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Math:
概述:
Math 包含執行基本數字運算的方法
調用方式:
Math類中無構造方法,但內部的方法都是靜態的,可以通過 類名.進行調用
常用方法:
| public static int abs(int a) | 返回參數的絕對值 |
| public static double ceil(double a) | 返回整數,向上取整 |
| public static double floor(double a) | 返回整數,向下取整 |
| public static int round(float a) | 返回整數,四舍五入, |
| public static int max(int a,int b) | 返回兩個int值中的較大值 |
| public static int min(int a,int b) | 返回兩個int值中的較小值 |
| public static double pow (double a,double b) | 返回a的b次冪的值 |
| public static double random() | 返回值為double的正值,[0.0,1.0) |
演示:
public static void main(String[] args) {// 返回參數的絕對值System.out.println(Math.abs(-10));// 返回整數,向上取整System.out.println(Math.ceil(10.9));// 返回整數,向下取整System.out.println(Math.floor(10.9));// 按照四舍五入返回最接近參數的intSystem.out.println(Math.round(10.2));// 返回兩個int值中的較大值System.out.println(Math.max(10, 20));// 返回兩個int值中的較小值System.out.println(Math.min(10, 20));// 返回a的b次冪的值System.out.println(Math.pow(2,3));// 返回值為double的正值,可以生成隨機數范圍是[0.0,1.0)System.out.println(Math.random());}System:
概念:
System類代表系統,系統級的很多屬性和控制方法都放置在該類的內部。該類位于java.lang包。
System類的常用方法 :
| public static void exit(int status) | 終止當前運行的 Java 虛擬機,非零表示異常終止 |
| public static long currentTimeMillis() | 返回當前時間(以毫秒為單位) |
| public static void arraycopy?(Object src, int srcPos, Object dest, int destPos, int length) | 數據源,起始索引,目的地數組,起始索引,拷貝個數 |
總結
以上是生活随笔為你收集整理的MathSystem的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 插入网站连接_带你了解网站设计的五个基本
- 下一篇: 仅展示近三天的动态设置_抱歉,朋友仅展示