String s="123";
int i=Integer.parseInt(s);

解决方案 »

  1.   

    有啊,很多的。
    比如:
    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.parseLong
    public static long parseLong(String s)
                          throws NumberFormatException
    Parses the string argument as a signed decimal long. 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 long value is returned, exactly as if the argument and the radix 10 were given as arguments to the parseLong(java.lang.String, int) method. 
    Note that neither the character L ('\u004C') nor l ('\u006C') is permitted to appear at the end of the string as a type indicator, as would be permitted in Java programming language source code. 
    Parameters:
    s - a String containing the long representation to be parsed 
    Returns:
    the long represented by the argument in decimal. 
    Throws: 
    NumberFormatException - if the string does not contain a parsable long.parseDouble
    public static double parseDouble(String s)
                              throws NumberFormatException
    Returns a new double initialized to the value represented by the specified String, as performed by the valueOf method of class Double. Parameters:
    s - the string to be parsed. 
    Returns:
    the double value represented by the string argument. 
    Throws: 
    NumberFormatException - if the string does not contain a parsable double.
    Since: 
    1.2 parseByte
    public static byte parseByte(String s)
                          throws NumberFormatException
    Parses the string argument as a signed decimal byte. 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 byte value is returned, exactly as if the argument and the radix 10 were given as arguments to the parseByte(java.lang.String, int) method. Parameters:
    s - a String containing the byte representation to be parsed 
    Returns:
    the byte value represented by the argument in decimal 
    Throws: 
    NumberFormatException - if the the string does not contain a parsable byte.
    其它的还有很多,你可以看java的api
      

  2.   


    Integer.parseInt("55464");
      

  3.   

    Java 中有很多的类型转换方法,通常在基本类型的包装类中,如Integer, Long, Double等,可以数字字符串转成相应的基本类型。另外也有强制转换,即cast。