parseFloat
java.lang 
Class Float
java.lang.Object
  |
  +-java.lang.Number
        |
        +-java.lang.FloatAll Implemented Interfaces: 
Comparable, Serializable public static float parseFloat(String s)
                        throws NumberFormatException
Returns a new float initialized to the value represented by the specified String, as performed by the valueOf method of class Float. Parameters:
s - the string to be parsed. 
Returns:
the float value represented by the string argument. 
Throws: 
NumberFormatException - if the string does not contain a parsable float.
Since:
1.2 
See Also:
valueOf(String)

解决方案 »

  1.   

    java.lang 
    Class Integer
    java.lang.Object
      |
      +-java.lang.Number
            |
            +-java.lang.IntegerAll Implemented Interfaces: 
    Comparable, Serializable 
    parseInt
    public static int parseInt(String s)
                        throws NumberFormatException
    Parses the string argument as a signed decimal integer. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('\u002D') to indicate a negative value. The resulting integer value is returned, exactly as if the argument and the radix 10 were given as arguments to the parseInt(java.lang.String, int) method. Parameters:
    s - a String containing the int representation to be parsed 
    Returns:
    the integer value represented by the argument in decimal. 
    Throws: 
    NumberFormatException - if the string does not contain a parsable integer.
      

  2.   

    Integer.parseInt(String)Float.parseFloat(String)