int Integer String之间的相互转换:
1、如图所示:
2、代码如下:
public static void main(String[] args) {
// String --> int
int a = Integer.parseInt("100");
System.out.println(a+1); // 101
// int --> String
String b = a +"";
System.out.println(b+1); // 1001
// int --> Integer
// 自动装箱
Integer c = a;
System.out.println(c+2); // 102
// Integer --> int
// 自动拆箱
int d = c;
System.out.println(d+2); // 102
// String --> Integer
Integer e = Integer.valueOf(b);
System.out.println(e+3); // 103
// Integer --> String
String f = String.valueOf(e);
System.out.println(f+3); // 1003
}
3、运行结果如下: