In this example we will show how to check if a number is infinite in Java.
Source Code
package com.beginner.examples;
public class IsInfinite {
public static void main(String[] args) {
Double num = new Double(2.0 / 0);
System.out.println(num.isInfinite()); // check if a number is infinite
}
}
Output:
true