1. package com.packclass;
    2. public class Demo08 {
    3. public static void main(String[] args) {
    4. // int -> String
    5. int i = 100;
    6. System.out.println(i + "");
    7. System.out.println(String.valueOf(100));
    8. // String -> int
    9. String s = "123";
    10. System.out.println(Integer.parseInt(s));
    11. // int -> Integer 自动装箱
    12. Integer a = i;
    13. System.out.println(a);
    14. // Integer -> int 自动拆箱
    15. int x = a.intValue();
    16. System.out.println(x);
    17. // String -> Integer
    18. Integer m = Integer.valueOf("abc");
    19. // Integer -> String
    20. String n = String.valueOf(1000);
    21. }
    22. }