开发者社区> 问答> 正文

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

已解决

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

展开
收起
游客gkv5feo4nm3qc 2022-04-03 15:27:14 1972 0
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
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
Spring Cloud Alibaba - 重新定义 Java Cloud-Native 立即下载
The Reactive Cloud Native Arch 立即下载
JAVA开发手册1.5.0 立即下载