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