Double isInfinite() method in Java

Java 8Object Oriented ProgrammingProgramming

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
raja
Published on 11-Dec-2018 06:09:57
Advertisements