Float.isFinite() in Java

Float.isFinite(): This method is available in java.lang.Float class of Java.

Syntax:

boolean java.lang.Float.isFinite(float f)

This method takes one argument of type float as its parameter. This method returns true if the argument is a finite floating-point value; returns false otherwise (for NaN and infinity arguments).

Parameters: One parameter is required for this method.

f: the float value to be tested.

Returns: true if the argument is a finite floating-point value, false otherwise.

For Example:

float f = (float) 199191.198

Float.isFinite(f) = > It returns true.

Approach

Java

public class FloatIsFinite {
    public static void main(String[] args) {

        float f = (float199191.198;
        System.out.println(Float.isFinite(f));

    }
}

Output:

true

No comments:

Post a Comment