您的位置:首页 > 其它

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();
 }
 
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息