How to determine If a Double Object Is Infinite in Java


Here this example demonstrates how to determine if a double object is Infinite using isInfinite() method of the Double class in Java.

Source Code

package com.beginner.examples;

public class DoubleIsInfinite {

	public static void main(String[] args) {

		Double d = new Double(1.0 / 0);

		// Use the isInfinite() method to determine if it isInfinite
		System.out.println(d.isInfinite());

	}

}

Output:

true
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments