开发者社区 问答 正文

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

已解决

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

展开
收起
游客gkv5feo4nm3qc 2022-04-03 15:27:14 2002 分享
分享
版权
举报
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 举报
    赞同 评论

    评论

    全部评论 (0)

    登录后可评论
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等