开发者社区 问答 正文

Java中以int和Integer为例,装箱和拆箱是如何操作的?

已解决

Java中以int和Integer为例,装箱和拆箱是如何操作的?

展开
收起
游客gkv5feo4nm3qc 2022-04-03 15:27:14 2039 分享 版权
1 条回答
写回答
取消 提交回答
  • 推荐回答

    以int和Integer为例

    public static void main(String args[]){

    Integer num = new Integer(1-10); //装箱

    int x = num.intValue(); //拆箱

    System.out.println(x*2);

    }

    }

    2022-04-03 15:41:58
    赞同 展开评论