public class Test1 { public static void main(String[] args) { int a = 3; Integer a1 = new Integer(a); Integer a2 = Integer.valueOf(a); // converting int into Integer Integer a3 = a; //autoboxing, now compiler will write Integer.valueOf(a) internally System.out.println(a1 instanceof Integer); System.out.println(a2 instanceof Integer); System.out.println(a3 instanceof Integer); int a4 = a1.intValue(); // converting Integer to int int a5 = a1; // unboxing, now compiler will write a.intValue() internally } }
java 拆箱装箱
最新推荐文章于 2023-04-25 00:27:16 发布