登录

java中Integer及自动装箱

//声明一个Integer对象
Integer num = 10;
//以上的声明就是用到了自动的装箱:解析为
Integer num = new Integer(10);
其中:可否理解为在Integer类中存在一个构造函数:

int a;
Integer (int a){
      this.a=a
}
把10存在构造函数里面了,
然后Integer按照以上理解来使用
# Java
高洛峰高洛峰2146 天前361 次浏览

全部回复(1) 我要回复

  • 迷茫

    迷茫2017-04-17 15:48:27

    哈哈,这个有趣的问题我可是要上java源码来证明你的答案啦!
    当然,你是正确的

    回复
    0
  • 取消回复发送