isinfinite
雙類isInfinite()方法 (Double class isInfinite() method)
isInfinite() method is available in java.lang package.
isInfinite()方法在java.lang包中可用。
isInfinite() method is used to check infinity (i.e. either positive infinity or negative infinity).
isInfinite()方法用于檢查無窮大(即正無窮大或負無窮大)。
isInfinite() 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.
isInfinite()方法是一種非靜態方法,只能通過類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。
isInfinite() method does not throw an exception at the time of checking infinity.
isInfinite()方法在檢查無窮大時不會引發異常。
Syntax:
句法:
public boolean isInfinite();
Parameter(s):
參數:
It does not accept any parameter.
它不接受任何參數。
Return value:
返回值:
The return type of this method is boolean, it returns "true" if this object is either positive or negative infinity, else it returns "false".
此方法的返回類型為boolean ,如果此對象是正無窮大或負無窮大,則返回“ true”,否則返回“ false”。
Example:
例:
// Java program to demonstrate the example
// of isInfinite() method of Double class
public class IsInfiniteOfDoubleClass {
public static void main(String[] args) {
// Object initialization
Double ob1 = new Double(10.0 / 0.0);
Double ob2 = new Double(-20.0 / 0.0);
Double ob3 = new Double(20.0);
// Display ob1,ob2 and ob3 values
System.out.println("ob1: " + ob1);
System.out.println("ob2: " + ob2);
System.out.println("ob3: " + ob3);
// It checks infinity by calling ob1.isInfinite() for ob1
// and ob2.isInfinite() for ob2 and ob2.isInfinite() for ob3
boolean infinite1 = ob1.isInfinite();
boolean infinite2 = ob2.isInfinite();
boolean infinite3 = ob3.isInfinite();
// Display result values
System.out.println("ob1.isInfinite(): " + infinite1);
System.out.println("ob2.isInfinite(): " + infinite2);
System.out.println("ob3.isInfinite(): " + infinite3);
}
}
Output
輸出量
ob1: Infinity
ob2: -Infinity
ob3: 20.0
ob1.isInfinite(): true
ob2.isInfinite(): true
ob3.isInfinite(): false
翻譯自: https://www.includehelp.com/java/double-class-isinfinite-method-with-example.aspx
isinfinite