Java Float.valueOf(String s)

Syntax

Float.valueOf(String s) has the following syntax.

public static Float valueOf(String s)   throws NumberFormatException

Example

In the following code shows how to use Float.valueOf(String s) method.


/*ww  w.j  a  v a 2 s  . co  m*/

public class Main {

   public static void main(String[] args) {

     String str = "0.56";

     System.out.println("Value = " +  Float.valueOf(str));
   }
}

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