parseFloat Method
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Float.parseFloat Method

Visual Studio 2005

Returns a float value specified by the string parameter.

Package: java.lang

Assembly: vjslib (in vjslib.dll)


public static float parseFloat(
    java.lang.String s) throws java.lang.NumberFormatException;

Parameters

s

A string expression.

The float value specified by s.

// f-parseF1.jsl
// Float.parseFloat example

public class MyClass
{
    public static void main(String[] args)
    {
        float f = Float.parseFloat("-2.45F");
        System.out.print("The float is: " + f);
    }
}

/*
Output:
The float is: -2.45
*/

The exception java.lang.NumberFormatException is thrown if the string cannot be parsed to a float value.

Show:
© 2016 Microsoft