int a = 10;
//int --> Integer
Integer b = new Integer(a);
//Integer --> int
int c = b.intValue();
//JDK5.0以后
//自动装箱:基本数据类型转换为数值包装类型
Integer d = a;
//自动拆箱:数值包装类型转换为基本数据类型
int e = d;
//以下非自动,需要调API
String s = "10";
//String --> int
int f = Integer.parseInt(s);
//String --> Integer
Integer g = new Integer(s);
Integer h = Integer.getInteger(s);
h = Integer.valueOf(s);
//int --> String
String i = 20 + "";//字符串拼接
String j = Integer.toString(20);
//Integer -->String
String k = h.toString();
转载:https://blog.csdn.net/fzq13994952987/article/details/102307445
查看评论