Double isInfinite() method in Java

Java 8Object Oriented ProgrammingProgramming

<p>The Double isInfinite() method returns true if this Double value is infinitely large in magnitude, false otherwise.</p><p>Let&rsquo;s say we have the following Double values.</p><pre class="result notranslate">Double val1 = new Double(3/0.); Double val2 = new Double(0/0.);</pre><p>Use the isInfinite() method now. The return value is a boolean.</p><pre class="result notranslate">val1.isInfinite(); val2.isInfinite();</pre><p>The following is the final example.</p><h2>Example</h2><p><a class="demo" href="" rel="nofollow" target="_blank">&nbsp;Live Demo</a></p><pre class="prettyprint notranslate">public class Demo { &nbsp; &nbsp;public static void main(String args[]) { &nbsp; &nbsp; &nbsp; Double val1 = new Double(3/0.); &nbsp; &nbsp; &nbsp; Double val2 = new Double(0/0.); &nbsp; &nbsp; &nbsp; System.out.println(val1.isInfinite()); &nbsp; &nbsp; &nbsp; System.out.println(val2.isInfinite()); &nbsp; &nbsp;} }</pre><h2>Output</h2><pre class="result notranslate">true false</pre>
Updated on 26-Jun-2020 08:51:51