Java Number floatValue() MethodThe floatValue() is a method of Java Number class which returns the float equivalent value of the specified Number object. It may also involve in rounding or truncation of the specified Number value. Syntax:Following is the declaration of floatValue() method: Parameter:
Returns:The floatValue() method will return the numeric value represented by this object after conversion to type float. Exceptions:NA Compatibility Version:Java 1.0 and above Example 1Test it NowOutput: Value : 2454.0 Value : 86549.984 Example 2<Output: Enter The Desired Input Value: 123ABCD Exception in thread "main" java.util.InputMismatchException at java.base/java.util.Scanner.throwFor(Scanner.java:939) at java.base/java.util.Scanner.next(Scanner.java:1594) at java.base/java.util.Scanner.nextInt(Scanner.java:2258) at java.base/java.util.Scanner.nextInt(Scanner.java:2212) at myPackage.NumberFloatValueExample2.main(NumberFloatValueExample2.java:9) Example 3Test it NowOutput: Value is = 1.5 Next TopicJava Number Class |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India