Java String.valueOf(float f)

Syntax

String.valueOf(float f) has the following syntax.

public static String valueOf(float f)

Example

In the following code shows how to use String.valueOf(float f) method.


public class Main {
  public static void main(String args[]) {
/*w ww.j  av  a  2 s . com*/
    float floatValue = 2.5f; // f indicates that 2.5 is a float
    System.out.printf("float = %s\n", String.valueOf(floatValue));
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable