public static void main(String[] args) {
//定义一个基本数据类型
int a=3;
//定义一个基本数据类型
Integer b=a;
//b是Integer 类定义的对象,直接用int 类型的a赋值
System.out.println(b);
//打印结果为3
}
public static Integer valueOf(int i) {
if (i >= ‐128 && i <= 127)
return IntegerCache.cache[i + 127];
return new Integer(i);
}int value。
Integer cache[];
static {
cache = new Integer[(127 ‐ (‐128)) + 1];
int j = low;
for(int k = 0; k < cache.length; k++){
cache[k] = new Integer(j++);
}
}
public static void main(String[] args) {
Integer b=new Integer(3);
//b为Integer的对象
int a=b;
//a为一个int的基本数据类型
}
public int intValue() {
return value;
}
public Integer(int value) {
this.value = value;
}
| 欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |