java.lang.Float floatToIntBits(float value)
Description
Method Syntax
public static boolean isFinite(float f)
Method Argument
Data Type | Parameter | Description |
---|---|---|
float | f | the float value to be tested |
Method Returns
The isFinite() method of Float class returns true if the argument is a finite floating-point value, false otherwise.
Compatibility
Java 1.8
Discussion
The method isFinite(float f) is simply a way to check if the method argument is a finite floating point. This is a very simple method of Float class however make note that this method is static. Thus it needs to be accessed statically which means that we should use this method in the format Float.isFinite(float f);
Java Float isFinite(float f) Example
Below is a simple java example on the usage of isFinite(float f) method of Float class.
package com.javatutorialhq.java.examples; import java.util.Scanner; import static java.lang.System.*; /* * This example source code demonstrates the use of * isFinite(float f) method of Float class. */ public class FloatIsFiniteExample { public static void main(String[] args) { // Ask user input System.out.print("Enter Desired Value:"); // declare the scanner object Scanner scan = new Scanner(System.in); // use scanner to get value from user console Float userInput = scan.nextFloat(); // close the scanner object scan.close(); // check if the float input is finite floating point boolean check = Float.isFinite(userInput); out.println("is the value entered finite? " + check); } }
Basically on the above example, we just ask for user input on the console and then we use the scanner object to get the float input. After that we assign the value to an Float wrapper class and we then we check if the user input is a finite floating point.