public class IntegerTest {
public static void main(String[] args) {
//String --> int
int i1 = Integer.parseInt("100");
System.out.println(i1 + 1);//int 101
//int --> String
String s2 = i1+ "";
System.out.println(s2 + 1);//"1001"
//int --> Integer
//自动装箱
Integer x = 1000;
System.out.println(x);
//Integer --> int
//自动拆箱
int y = x;
System.out.println(y);
//String --> Integer
Integer k = Integer.valueOf("123");
System.out.println(k);
//Integer --> String
String e = String.valueOf(k);
System.out.println(e);
}
}
输出
101
1001
1000
1000
123
123