1、String类型—> 基本数据类型、包装类,调用包装类的parseXxx()
String str1 = "123";
int num2 = Integer.parseInt(str1);
System.out.println(num2 + 1);
2、基本数据类型、包装类—> String类型,调用String重载的valueOf(Xxx xxx)
int num1 = 10;
方式1:连接运算
String str1 = num1 + "";
float f1 = 12.3f;
String str2 = String.valueOf(f1);
3、基本数据类型 --> 包装类的对象
方式一:
int num2 = 10;
Integer in1 = num2;
方式二:
Integer in1 = new Integer(num1);
4、包装类的对象 --> 基本数据类型
方式一:
int num2 = 10;
Integer in1 = num2;
int num3 = in1;
方式二:
Integer in1 = new Integer(12);
int i1 = in1.intValue();