1、字符型轉(zhuǎn)換成整型:
1.轉(zhuǎn)換成Int型
int/Integer num = Integer.parseInt(String str);
2.轉(zhuǎn)換成long型
Long/long num = Long.parseLong(String str);
3.轉(zhuǎn)換成short型
short/Short num = Short.parseShort(String str);
4.轉(zhuǎn)換成float型
float/Float num = Float.parseFloat(String str);
5.轉(zhuǎn)換成double型
double/Double num = Double.parseDouble(String str);
2、整型轉(zhuǎn)換成字符型
1.整型轉(zhuǎn)換成字符型
String num = Integer.toString(int n);
2.Long型轉(zhuǎn)換成字符型
String num = Long.toString(long n);
3.Short型轉(zhuǎn)換成字符型
String num = Short.toString(Short n);
4.Float型轉(zhuǎn)換成字符型
String num = Float.toString(Float n);
5.Double型轉(zhuǎn)換成字符型
String num = Double.toString(Double n);
聯(lián)系客服