日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

java 根据类名示例化类_Java MathContext类| 带示例的getRoundingMode()方法

發布時間:2025/3/11 51 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java 根据类名示例化类_Java MathContext类| 带示例的getRoundingMode()方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

java 根據類名示例化類

MathContext類的getRoundingMode()方法 (MathContext Class getRoundingMode() method)

  • getRoundingMode() method is available in java.math package.

    getRoundingMode()方法在java.math包中可用。

  • getRoundingMode() method is used to get the RoundingMode value of this MathContext if defined and there are many constants of Rounding Mode like DOWN, CEILING, UNNECESSARY, FLOOR, etc.

    如果已定義,則getRoundingMode()方法用于獲取此MathContext的RoundingMode值,并且舍入模式有許多常量,如DOWN,CEILING,UNNECESSARY,FLOOR等。

  • getRoundingMode() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    getRoundingMode()方法是一種非靜態方法,僅可通過類對象訪問,如果嘗試使用類名訪問該方法,則會收到錯誤消息。

  • getRoundingMode() method does not throw an exception at the time of getting round mode.

    在獲取回合模式時, getRoundingMode()方法不會引發異常。

Syntax:

句法:

public RoundingMode getRoundingMode();

Parameter(s):

參數:

  • None

    沒有

Return value:

返回值:

The return type of this method is RoundingMode, it returns the RoundingMode constants whatever be defined with this MathContext.

此方法的返回類型為RoundingMode ,無論此MathContext定義什么,它都會返回RoundingMode常量。

Example:

例:

// Java program to demonstrate the example // of RoundingMode getRoundingMode() method of MathContextimport java.math.*;public class GetRoundingModeOfMC {public static void main(String args[]) {// Initialize three MathContext objects MathContext ma_co1 = new MathContext(3, RoundingMode.CEILING);MathContext ma_co2 = new MathContext(4);MathContext ma_co3 = new MathContext(6, RoundingMode.FLOOR);// returns the rounding mode of this MathContext// ma_co1 i.e. RoundingMode is the second// parameter set in MathContext Constructor// i.e. CEILING in ma_co1RoundingMode rm = ma_co1.getRoundingMode();System.out.println("ma_co1.getRoundingMode(): " + rm);// returns the rounding mode of this MathContext// ma_co2 i.e. RoundingMode is the second// parameter set in MathContext Constructor// i.e. HALF_UP in ma_co2 it the default set// when we don't use other rounding moderm = ma_co2.getRoundingMode();System.out.println("ma_co2.getRoundingMode(): " + rm);// returns the rounding mode of this MathContext// ma_co3 i.e. RoundingMode is the second// parameter set in MathContext Constructor// i.e. FLOOR in ma_co1rm = ma_co3.getRoundingMode();System.out.println("ma_co3.getRoundingMode(): " + rm);} }

Output

輸出量

ma_co1.getRoundingMode(): CEILING ma_co2.getRoundingMode(): HALF_UP ma_co3.getRoundingMode(): FLOOR

翻譯自: https://www.includehelp.com/java/mathcontext-getroundingmode-method-with-example.aspx

java 根據類名示例化類

總結

以上是生活随笔為你收集整理的java 根据类名示例化类_Java MathContext类| 带示例的getRoundingMode()方法的全部內容,希望文章能夠幫你解決所遇到的問題。

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