JAVA中常用数据类型转换函数 string->byte
Byte static byte parseByte(String s)  
 
byte->string 
Byte static String toString(byte b) 
 
char->string 
Character static String to String (char c) 
 
string->Short 
Short static Short parseShort(String s) 
 
Short->String 
Short static String toString(Short s) 
 
String->Integer 
Integer static int parseInt(String s)
 
Integer->String 
Integer static String tostring(int i) 
 
String->Long 
Long static long parseLong(String s) 
 
Long->String 
Long static String toString(Long i) 
 
String->Float 
Float static float parseFloat(String s) 
 
Float->String 
Float static String toString(float f) 
 
String->Double 
Double static double parseDouble(String s)
 
Double->String
Double static String toString(Double 

解决方案 »

  1.   

    用 float t=Float.parseFloat(String s);
      

  2.   

    f=Float.parseFloat(str)将String对象转换测绘那嘎float类型!
      

  3.   

    String s="123.45";
            Float f1=Float.valueOf(s);
            float f2=Float.parseFloat(s);
            Float f3=new Float(s);
      

  4.   

    如果一个String是"abcdefg",能转成float型吗?
    呵呵……
    如果在转变的时候类型不对,会报一个NunberFormatException
      

  5.   

    String s="abc";
    float f;
    f=Float.parseFloat(str);
    呵呵