zl程序教程

您现在的位置是:首页 >  后端

当前栏目

Java int和Integer的自动装箱与拆箱

JAVA自动 int Integer 装箱 拆箱
2023-09-27 14:24:43 时间

请参考这篇文章:https://www.cnblogs.com/joshua317/p/14522701.html

 

package com.joshua317;

public class Main {

    public static void main(String[] args) {
        //装箱,自动调用Integer.valueOf(100)
        Integer a = 100;
        //拆箱,自动调用a.intValue()
        int b = a;
        System.out.println(a==b);
    }
}