码迷,mamicode.com
首页 > 其他好文 > 详细

Int与Integer的区别

时间:2019-04-01 14:18:57      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:补充   bsp   扩展   引用   基本类型   基本数据   int   integer   拆箱   

int和integer的区别

      1. Ingeter是int的包装类,int的初值为0,Ingeter的初值为null;

      2.初始化的时候,int i =1;Integer i= new Integer(1);(要把integer 当做一个类看);但由于有了自动装箱和拆箱使得对Integer类也可使用:Integer i= 1;    

      3.int 是基本数据类型(面向过程留下的痕迹,不过是对java的有益补充),Integer 是一个类,是int的扩展,定义了很多的转换方法

      4.Integer是对象,用一个引用指向这个对象,而int是基本类型,直接存储数值。

Int与Integer的区别

标签:补充   bsp   扩展   引用   基本类型   基本数据   int   integer   拆箱   

原文地址:https://www.cnblogs.com/5aixin/p/10635980.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!