基本数据类型: char(16位), byte(8位), short(16位), int(32位), long, float, double, boolean
基本数据类型对应类:Character,Byte,Short,Integer,Long,Float,Double,Boolean, String
几乎所有类型类都有相似的方法用来转换为String类型,以及基本数据类型
Integer.parseInt(String?s) //将字符串参数作为有符号的十进制整数进行解析
Integer.parseInt(String?s, int?radix) //使用第二个参数指定的基数,将字符串参数解析为指定进制的整数。
Integer integer = new Integer("5");
int i0 = integer.intValue();
float f0 = integer.floatValue();
double d0 = integer.doubleValue();
String s0 = integer.toBinaryString(i0);
String s1 = integer.toHexString(i0);
String s2 = integer.toString(i0);
int i1 = (integer.valueOf(i0)).intValue();
Float f = new Float("9");
float f1 = f.floatValue();
byte b = f.byteValue();
float f2 = f.parseFloat("9");
Float ff = f.valueOf(f1);
本文介绍了Java中的基本数据类型及其对应的包装类,并详细讲解了如何通过这些包装类实现不同类型之间的转换,包括字符串到基本类型的转换及反向操作。

被折叠的 条评论
为什么被折叠?



