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

请参考这篇文章: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);
    }
}

 

posted @ 2021-11-24 19:12  joshua317  阅读(42)  评论(0编辑  收藏  举报