包装类
原始数据类型 | 包装类 |
---|---|
byte | Byte |
short | Short |
int | Integer |
long | Long |
float | Float |
double | Double |
boolean | Boolean |
char | Character |
拆箱和拆箱:
//装箱
int i;
Integer integer=new Integer(i);
//拆箱
int j=integer.intValue();
基本数据类型转换字符串类型
int a = 1;
String a1 = Integer.toString(a);
字符串类型转换成基本数据类型
String a = "1";
int a1 = Integer.parseInt(a);