J2SE 新特性, 自动拆箱和装箱。
2008-03-20 16:58
369 查看
package com.test;
/**
* J2SE 新特性, 自动拆箱和装箱。
*
*/
public class AutoBox {
/**
* 基本数据
*/
public static void intAutoBox(){
int i = 1000;
//可以把基本数据类形直接赋给对象
Integer iObj = 200; //直接装箱
Integer tempObj = iObj;
iObj = 444;
System.out.println(tempObj);
System.out.println(iObj);
// iObj = i;
// i = tempObj; //将对象拆箱
//
//
// iObj += i + tempObj;
// i *= iObj + tempObj;
}
public static void main(String[] args) throws Exception{
intAutoBox();
}
}
/**
* J2SE 新特性, 自动拆箱和装箱。
*
*/
public class AutoBox {
/**
* 基本数据
*/
public static void intAutoBox(){
int i = 1000;
//可以把基本数据类形直接赋给对象
Integer iObj = 200; //直接装箱
Integer tempObj = iObj;
iObj = 444;
System.out.println(tempObj);
System.out.println(iObj);
// iObj = i;
// i = tempObj; //将对象拆箱
//
//
// iObj += i + tempObj;
// i *= iObj + tempObj;
}
public static void main(String[] args) throws Exception{
intAutoBox();
}
}
相关文章推荐
- J2SE 5.0新特性(四)自动装箱/拆箱
- J2SE 5.0新特性(四)自动装箱/拆箱
- 黑马程序员-jdk1.5新特性--基本数据类型的自动拆箱与装箱
- [Java5新特性]自动装箱/拆箱
- [J2SE 5.0专题]自动装箱和自动拆箱
- J2SE5.0新特性之自动装箱解箱
- 【学习总结】java高级特性之自动拆箱和装箱
- Java JDK5.0的新特性 增强for循环 自动装箱/拆箱 可变参数 静态导入
- jdk1.5新特性之-----自动装箱与自动拆箱
- 黑马程序员——Java1.5新特性之享元模式、增强for循环、可变参数、静态导入、自动装箱和拆箱
- JDK1.5新特性之---自动装箱/拆箱
- JDK1.5新特性--自动装箱与拆箱
- Java5.0新特性02-自动装箱与拆箱(Autoboxing/Autounboxing)
- jdk1.5新特性之自动装箱与自动拆箱
- day9 JDK 新特性--注解、新 for 循环、静态导入、自动装箱拆箱、泛型、可变长参数
- 1.5新特性静态导入、增强for、可变参数、自动装箱拆箱、枚举
- java1.5 新特性 自动装箱和拆箱
- 《黑马程序员》 jdk 1.5的新特性:自动装箱与拆箱练习及享元设计模式
- JDK5.0新特性系列---1.自动装箱和拆箱
- JDK5.0新特性(静态导入、自动装箱/拆箱、增强for循环、可变参数、枚举、泛形)