Java Float isInfinite Method - Java Language Basics

Java examples for Language Basics:float

Introduction

boolean isInfinite(float) static method checks whether the argument primitive float value is infinite number or not.

It return true if the specified argument is infinite value, false otherwise.

Demo Code


public class Main {
 
  public static void main(String[] args) {
 
    float f = (float) 1/0;
    boolean b1 = Float.isInfinite(f);
    System.out.println(b1);/*ww w .j a v a2s  .c om*/
 
    Float fObj = new Float(f);
    boolean b2 = fObj.isInfinite();
    System.out.println(b2);
 
  }
}

Result


Related Tutorials