int和integer区别,怎么样互相转换?(八种基础类型)

int是基础类型,integer是int的封装类
int存放在栈空间,integer作为对象放在堆空间
integer默认是null,int默认值是0;
声明integer的变量需要实例化,而申明int的变量不需要实例化
integer是对象,用一个引用指向这个对象,int是基本类型,直接存储数值


八种基础类型及对应的封装类

1、byte  Byte
2、short Short
3、int   Integer
4、long Long
5、double Double
6、float Float
7、boolean Boolean
8、char Characher

猜你喜欢

转载自www.cnblogs.com/lhh666/p/11912378.html