Colorful Day
Blue keywords,Green comment,Red breakpoint,my life is also colorful
BlogJava
首页
新随笔
联系
聚合
管理
随笔分类
AJAX(9)
(rss)
chit chat(6)
(rss)
EJB and APP Server
(rss)
JAVA foundation(5)
(rss)
MVC Framework(3)
(rss)
ORM(3)
(rss)
Spring(1)
(rss)
随笔档案
2006年7月 (2)
2006年6月 (4)
2006年3月 (9)
2006年2月 (4)
2005年12月 (2)
2005年11月 (4)
2005年10月 (4)
最新随笔
1. 拉拉
2. RSS订阅服务扩展
3. 从codes学java tiger之varargs
4. 从code学习java tiger之自动装箱 拆箱
5. 从code学习java tiger 之 枚举
6. 从codes学java tiger之范型
7. [导入]Hibernate Performance Tuning
8. [导入]Hibernate POJO's good assistant-Commons for Eclipse
9. [导入]AJAX tool box---Venkman
10. [导入]No more crap about IE Memeory Leak
最新评论
1. 请教[未登录]
在eclipse+dreamwaver 8编程时,文件在dreamwaver中可以显示但在eclipse中没有显示,为什么??请多多指教??万分感谢,我的邮箱是 lingqiaoxu@sina.com
--ling
2. re: AJAX贴贴脸 入门篇
2546
--45
3. re: Behaviour.js 真正的清洁了html?
评论内容较长,点击标题查看
--拐拐龙底咚
从code学习java tiger之自动装箱 拆箱
Posted on 2006-06-22 18:34
BlueO2
阅读(184)
评论(0)
编辑
收藏
所属分类:
JAVA foundation
public
class
AutoBoxing
{
/** */
/**
Creates a new instance of AutoBoxing
*/
public
AutoBoxing()
{
}
public
void
boxingDemo()
{
//
auto boxing
Integer i
=
0
;
float
f
=
1.66f
;
Float F
=
f;
//
auto unboxing
Integer I
=
new
Integer(
1
);
int
i2
=
I;
//
null value test, it will case NullPointerException
Integer I2
=
null
;
int
i3
=
I2;
}
public
void
testOperator()
{
Integer i
=
1
;
while
(
true
)
{
i
++
;
System.out.println(
"
Counter:
"
+
i);
if
(i
>
5
)
break
;
}
}
public
void
testCompare()
{
//
it's equal because -127~127 are immutable objects
Integer i
=
1
;
Integer i2
=
1
;
if
(i
==
i2) System.out.println(
"
1:Equal
"
);
else
System.out.println(
"
1:Not Equal
"
);
//
it's not equal because j and j2 are different objects
Integer j
=
200
;
Integer j2
=
200
;
if
(j
==
j2) System.out.println(
"
200:Equal
"
);
else
System.out.println(
"
200:Not Equal
"
);
}
public
void
testControl()
{
Boolean flag
=
true
;
Integer i
=
20
;
Integer j
=
30
;
if
(flag)
{
System.out.println(
"
Boolean affects
"
);
}
if
(i
<
j)
System.out.println(
"
Integer affects
"
);
}
public
void
testMethod(
double
arg)
{
System.out.println(
"
public void testMethod(double arg) is invoked
"
);
}
public
void
testMethod(Integer arg)
{
System.out.println(
"
public void testMethod2(Integer arg) is invoked
"
);
}
public
static
void
main(String args[])
{
AutoBoxing auto
=
new
AutoBoxing();
auto.testCompare();
auto.testOperator();
auto.testControl();
int
i
=
1
;
//
public void testMethod(Integer arg) wouldn't be invoked
//
because public void testMethod(double arg) will be invoked in JDK1.4
//
Java tiger consider the backward capability
auto.testMethod(i);
auto.boxingDemo();
}
}
IT新闻
新用户注册
刷新评论列表
标题
姓名
主页
验证码
*
内容(请不要发表任何与政治相关的内容)
Remember Me?
登录
使用高级评论
新用户注册
返回页首
恢复上次提交
[使用Ctrl+Enter键可以直接提交]
推荐图书:
《
走出软件作坊
》、《
悟透JavaScript
》、《
Head First 设计模式
》
相关文章:
从codes学java tiger之varargs
从code学习java tiger之自动装箱 拆箱
从code学习java tiger 之 枚举
从codes学java tiger之范型
斗胆给Thinking in JAVA挑错
相关链接:
网站导航:
博客园
BlogJava
博客生活
IT博客网
C++博客
PHP博客
博客园社区
管理博客
教师博客
天文博客
汽车博客
足球博客
股票博客
电子博客
管理
公告
Name:
David
Age:
23
blueoxygen_cn(at)msn.com
5245091
blueoxygen(at)Gmail.com
常用链接
我的随笔
我的评论
我的参与
最新评论
Blogger's
评论排行榜
1. [collection]struts download Action(1)
2. AJAX贴贴脸 入门篇 (1)
3. Behaviour.js 真正的清洁了html?(1)
4. 理清一下路线,集中力量办大事(0)
5. 斗胆给Thinking in JAVA挑错(0)
阅读排行榜
1. AJAX贴贴脸 入门篇 (1286)
2. [导入]AJAX Auto-complete component(571)
3. Hibernate mapping summarize(487)
4. Behaviour.js 真正的清洁了html?(461)
5. Javascript操作xml小小showcase:xml转换为table(420)
posts - 29, comments - 3, trackbacks - 0, articles - 0
Copyright © BlueO2