Float.toString(): This method is available in java.lang.Float class of Java.
Syntax:
String java.lang.Float.toString(float f)
This method takes one argument of type float as its parameter. This method returns a string representation of the float argument.
Note:
1. If the argument is NaN, the result is the string"NaN".
2. Otherwise, the result is a string that represents the sign and magnitude (absolute value) of the argument.
Parameters: One parameter is required for this method.
f: the float to be converted.
Returns: a string representation of the argument.
For Example:
float f = 1919.5f
Float.toString(f) = > It returns 1919.5
Approach
Java
public class FloattoString {public static void main(String[] args) {float f = 1919.5f;System.out.println(Float.toString(f));}}
Output:
1919.5
No comments:
Post a Comment