日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

number java_java中Number Math 类方法

發布時間:2025/3/15 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 number java_java中Number Math 类方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

package NumberAndMath;

/**

* Number and Math 方法

* @author Administrator

*

*/

public class NumAndMathDome {

public static void main(String[] args) {

/**

* xxxValue

* 將 Number 對象轉換為xxx數據類型的值并返回

*/

Integer x =10;

System.out.println("x is byte:"+x.byteValue());

System.out.println("x is double:"+x.doubleValue());

System.out.println("x is shor:"+x.shortValue());

System.out.println("x is long:"+x.longValue());

System.out.println("x is float:"+x.floatValue());

/**

* compareTo

* number類與參數做比較,若比較相等返回0,大于返回1,小于返回-1

*/

Integer x =15;

System.out.println(x.compareTo(17));

System.out.println(x.compareTo(15));

System.out.println(x.compareTo(10));

/**

* equals()

* 判斷number對象是否與參數相等,相等則返回ture,否則false

*/

Integer x =44;

Integer y =20;

Integer z =44;

System.out.println(x.equals(y));

System.out.println(x.equals(z));

/**

* round() 方法返回一個最接近的int、long型值

*/

double a =101.568;

double b = 200.4;

float c = 83f;

System.out.println(Math.round(a));//返回值為102

System.out.println(Math.round(b));//返回值為200

System.out.println(Math.round(c));//返回值為83

/**

* math.max() math.min() 返回最大值和最小值

*/

System.out.println(Math.max(23, 44));

System.out.println(Math.min(44, 3));

}

/**

* random()隨機數,不接受任何參數

*/

System.out.println(Math.random());

}

}

}

總結

以上是生活随笔為你收集整理的number java_java中Number Math 类方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。