Double isInfinite() method in Java


The Double isInfinite() method returns true if this Double value is infinitely large in magnitude, false otherwise.

Let’s say we have the following Double values.

Double val1 = new Double(3/0.);
Double val2 = new Double(0/0.);

Use the isInfinite() method now. The return value is a boolean.

val1.isInfinite();
val2.isInfinite();

The following is the final example.

Example

 Live Demo

public class Demo {
   public static void main(String args[]) {
      Double val1 = new Double(3/0.);
      Double val2 = new Double(0/0.);
      System.out.println(val1.isInfinite());
      System.out.println(val2.isInfinite());
   }
}

Output

true
false

Updated on: 26-Jun-2020

91 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements