黑马程序员技术交流社区
标题:
看之前大神的技术博客看到的不懂的地方 1
[打印本页]
作者:
吉吉粥
时间:
2015-10-21 22:47
标题:
看之前大神的技术博客看到的不懂的地方 1
Integer x=128;
Integer y=128;
x==y (false)
Integer m=127;
Integer n=127;
m==n ( true)
为什么???上面 判定 是 错误的,下面是正确的。
1.int是基本的数据类型;
2.Integer是int的封装类;
3.int和Integer都可以表示某一个数值;
4.int和Integer不能够互用,因为他们两种不同的数据类型;
举例说明
ArrayList al=new ArrayList();
int n=40;
Integer nI=new Integer(n);
al.add(n);//不可以
al.add(nI);//可以
复制代码
附上取值范围
byte的取值范围为-128~127,占用1个字节(-2的7次方到2的7次方-1)
short的取值范围为-32768~32767,占用2个字节(-2的15次方到2的15次方-1)
int的取值范围为(-2147483648~2147483647),占用4个字节(-2的31次方到2的31次方-1)
long的取值范围为(-9223372036854774808~9223372036854774807),占用8个字节(-2的63次方到2的63次方-1)
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2