﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Colorful Day-随笔分类-JAVA foundation</title><link>http://www.blogjava.net/blueoxygen/category/3742.html</link><description>Blue keywords,Green comment,Red breakpoint,my life is also colorful</description><language>zh-cn</language><lastBuildDate>Fri, 02 Mar 2007 06:34:48 GMT</lastBuildDate><pubDate>Fri, 02 Mar 2007 06:34:48 GMT</pubDate><ttl>60</ttl><item><title>从codes学java tiger之varargs</title><link>http://www.blogjava.net/blueoxygen/archive/2006/06/26/55211.html</link><dc:creator>BlueO2</dc:creator><author>BlueO2</author><pubDate>Mon, 26 Jun 2006 12:25:00 GMT</pubDate><guid>http://www.blogjava.net/blueoxygen/archive/2006/06/26/55211.html</guid><wfw:comment>http://www.blogjava.net/blueoxygen/comments/55211.html</wfw:comment><comments>http://www.blogjava.net/blueoxygen/archive/2006/06/26/55211.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/blueoxygen/comments/commentRss/55211.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/blueoxygen/services/trackbacks/55211.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img id="Codehighlighter1_20_555_Open_Image" onclick="this.style.display='none'; Codehighlighter1_20_555_Open_Text.style.display='none'; Codehighlighter1_20_555_Closed_Image.style.display='inline'; Codehighlighter1_20_555_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
				<img id="Codehighlighter1_20_555_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_20_555_Closed_Text.style.display='none'; Codehighlighter1_20_555_Open_Image.style.display='inline'; Codehighlighter1_20_555_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000"> Artist </span>
				<span id="Codehighlighter1_20_555_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.blogjava.net/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_20_555_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    String[] others;<br /><img id="Codehighlighter1_52_90_Open_Image" onclick="this.style.display='none'; Codehighlighter1_52_90_Open_Text.style.display='none'; Codehighlighter1_52_90_Closed_Image.style.display='inline'; Codehighlighter1_52_90_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_52_90_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_52_90_Closed_Text.style.display='none'; Codehighlighter1_52_90_Open_Image.style.display='inline'; Codehighlighter1_52_90_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_52_90_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/** */</span>
						<span id="Codehighlighter1_52_90_Open_Text">
								<span style="COLOR: #008000">/**</span>
								<span style="COLOR: #008000"> Creates a new instance of Artist </span>
								<span style="COLOR: #008000">*/</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_112_118_Open_Image" onclick="this.style.display='none'; Codehighlighter1_112_118_Open_Text.style.display='none'; Codehighlighter1_112_118_Closed_Image.style.display='inline'; Codehighlighter1_112_118_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_112_118_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_112_118_Closed_Text.style.display='none'; Codehighlighter1_112_118_Open_Image.style.display='inline'; Codehighlighter1_112_118_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> Artist() </span>
						<span id="Codehighlighter1_112_118_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_112_118_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_168_289_Open_Image" onclick="this.style.display='none'; Codehighlighter1_168_289_Open_Text.style.display='none'; Codehighlighter1_168_289_Closed_Image.style.display='inline'; Codehighlighter1_168_289_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_168_289_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_168_289_Closed_Text.style.display='none'; Codehighlighter1_168_289_Open_Image.style.display='inline'; Codehighlighter1_168_289_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> Artist(String name,String <img src="http://www.blogjava.net/images/dot.gif" /> others)</span>
						<span id="Codehighlighter1_168_289_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_168_289_Open_Text">
								<span style="COLOR: #000000">{<br /><img id="Codehighlighter1_204_253_Open_Image" onclick="this.style.display='none'; Codehighlighter1_204_253_Open_Text.style.display='none'; Codehighlighter1_204_253_Closed_Image.style.display='inline'; Codehighlighter1_204_253_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_204_253_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_204_253_Closed_Text.style.display='none'; Codehighlighter1_204_253_Open_Image.style.display='inline'; Codehighlighter1_204_253_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">for</span>
								<span style="COLOR: #000000">(String other : others)</span>
								<span id="Codehighlighter1_204_253_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.blogjava.net/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_204_253_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            System.out.println(other);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">this</span>
								<span style="COLOR: #000000">.others </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> others;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_337_387_Open_Image" onclick="this.style.display='none'; Codehighlighter1_337_387_Open_Text.style.display='none'; Codehighlighter1_337_387_Closed_Image.style.display='inline'; Codehighlighter1_337_387_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_337_387_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_337_387_Closed_Text.style.display='none'; Codehighlighter1_337_387_Open_Image.style.display='inline'; Codehighlighter1_337_387_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> wildestMethod(Object <img src="http://www.blogjava.net/images/dot.gif" /> objs)</span>
						<span id="Codehighlighter1_337_387_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_337_387_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
								<span style="COLOR: #008000">//</span>
								<span style="COLOR: #008000">this method will accept any arguments</span>
								<span style="COLOR: #008000">
										<br />
										<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />
								</span>
								<span style="COLOR: #000000">    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_431_548_Open_Image" onclick="this.style.display='none'; Codehighlighter1_431_548_Open_Text.style.display='none'; Codehighlighter1_431_548_Closed_Image.style.display='inline'; Codehighlighter1_431_548_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_431_548_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_431_548_Closed_Text.style.display='none'; Codehighlighter1_431_548_Open_Image.style.display='inline'; Codehighlighter1_431_548_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">static</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> main(String[] args)</span>
						<span id="Codehighlighter1_431_548_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_431_548_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        Artist artist </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">new</span>
								<span style="COLOR: #000000"> Artist(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">You</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">, </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">, </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">2</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        artist.wildestMethod(</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">, </span>
								<span style="COLOR: #000000">3.5</span>
								<span style="COLOR: #000000">, </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">AA</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">, </span>
								<span style="COLOR: #0000ff">new</span>
								<span style="COLOR: #000000"> Artist());<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
<img src ="http://www.blogjava.net/blueoxygen/aggbug/55211.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/blueoxygen/" target="_blank">BlueO2</a> 2006-06-26 20:25 <a href="http://www.blogjava.net/blueoxygen/archive/2006/06/26/55211.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>从code学习java tiger之自动装箱 拆箱</title><link>http://www.blogjava.net/blueoxygen/archive/2006/06/22/54554.html</link><dc:creator>BlueO2</dc:creator><author>BlueO2</author><pubDate>Thu, 22 Jun 2006 10:34:00 GMT</pubDate><guid>http://www.blogjava.net/blueoxygen/archive/2006/06/22/54554.html</guid><wfw:comment>http://www.blogjava.net/blueoxygen/comments/54554.html</wfw:comment><comments>http://www.blogjava.net/blueoxygen/archive/2006/06/22/54554.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/blueoxygen/comments/commentRss/54554.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/blueoxygen/services/trackbacks/54554.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img id="Codehighlighter1_24_2037_Open_Image" onclick="this.style.display='none'; Codehighlighter1_24_2037_Open_Text.style.display='none'; Codehighlighter1_24_2037_Closed_Image.style.display='inline'; Codehighlighter1_24_2037_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
				<img id="Codehighlighter1_24_2037_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_24_2037_Closed_Text.style.display='none'; Codehighlighter1_24_2037_Open_Image.style.display='inline'; Codehighlighter1_24_2037_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000"> AutoBoxing </span>
				<span id="Codehighlighter1_24_2037_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.blogjava.net/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_24_2037_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img id="Codehighlighter1_35_77_Open_Image" onclick="this.style.display='none'; Codehighlighter1_35_77_Open_Text.style.display='none'; Codehighlighter1_35_77_Closed_Image.style.display='inline'; Codehighlighter1_35_77_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_35_77_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_35_77_Closed_Text.style.display='none'; Codehighlighter1_35_77_Open_Image.style.display='inline'; Codehighlighter1_35_77_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_35_77_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/** */</span>
						<span id="Codehighlighter1_35_77_Open_Text">
								<span style="COLOR: #008000">/**</span>
								<span style="COLOR: #008000"> Creates a new instance of AutoBoxing </span>
								<span style="COLOR: #008000">*/</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_103_109_Open_Image" onclick="this.style.display='none'; Codehighlighter1_103_109_Open_Text.style.display='none'; Codehighlighter1_103_109_Closed_Image.style.display='inline'; Codehighlighter1_103_109_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_103_109_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_103_109_Closed_Text.style.display='none'; Codehighlighter1_103_109_Open_Image.style.display='inline'; Codehighlighter1_103_109_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> AutoBoxing() </span>
						<span id="Codehighlighter1_103_109_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_103_109_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_139_425_Open_Image" onclick="this.style.display='none'; Codehighlighter1_139_425_Open_Text.style.display='none'; Codehighlighter1_139_425_Closed_Image.style.display='inline'; Codehighlighter1_139_425_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_139_425_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_139_425_Closed_Text.style.display='none'; Codehighlighter1_139_425_Open_Image.style.display='inline'; Codehighlighter1_139_425_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> boxingDemo()</span>
						<span id="Codehighlighter1_139_425_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_139_425_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #008000">//</span>
								<span style="COLOR: #008000">auto boxing</span>
								<span style="COLOR: #008000">
										<br />
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
								</span>
								<span style="COLOR: #000000">        Integer i </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">0</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">float</span>
								<span style="COLOR: #000000"> f </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">1.66f</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        Float F </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> f;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #008000">//</span>
								<span style="COLOR: #008000">auto unboxing</span>
								<span style="COLOR: #008000">
										<br />
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
								</span>
								<span style="COLOR: #000000">        Integer I </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">new</span>
								<span style="COLOR: #000000"> Integer(</span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">int</span>
								<span style="COLOR: #000000"> i2 </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> I;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #008000">//</span>
								<span style="COLOR: #008000">null value test, it will case NullPointerException</span>
								<span style="COLOR: #008000">
										<br />
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
								</span>
								<span style="COLOR: #000000">        Integer I2 </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">null</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">int</span>
								<span style="COLOR: #000000"> i3 </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> I2;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_457_607_Open_Image" onclick="this.style.display='none'; Codehighlighter1_457_607_Open_Text.style.display='none'; Codehighlighter1_457_607_Closed_Image.style.display='inline'; Codehighlighter1_457_607_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_457_607_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_457_607_Closed_Text.style.display='none'; Codehighlighter1_457_607_Open_Image.style.display='inline'; Codehighlighter1_457_607_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> testOperator()</span>
						<span id="Codehighlighter1_457_607_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_457_607_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        Integer i </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">;<br /><img id="Codehighlighter1_501_601_Open_Image" onclick="this.style.display='none'; Codehighlighter1_501_601_Open_Text.style.display='none'; Codehighlighter1_501_601_Closed_Image.style.display='inline'; Codehighlighter1_501_601_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_501_601_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_501_601_Closed_Text.style.display='none'; Codehighlighter1_501_601_Open_Image.style.display='inline'; Codehighlighter1_501_601_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">while</span>
								<span style="COLOR: #000000">(</span>
								<span style="COLOR: #0000ff">true</span>
								<span style="COLOR: #000000">)</span>
								<span id="Codehighlighter1_501_601_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.blogjava.net/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_501_601_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            i</span>
										<span style="COLOR: #000000">++</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            System.out.println(</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">Counter:</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">+</span>
										<span style="COLOR: #000000">i);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000">(i</span>
										<span style="COLOR: #000000">&gt;</span>
										<span style="COLOR: #000000">5</span>
										<span style="COLOR: #000000">) </span>
										<span style="COLOR: #0000ff">break</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_638_1067_Open_Image" onclick="this.style.display='none'; Codehighlighter1_638_1067_Open_Text.style.display='none'; Codehighlighter1_638_1067_Closed_Image.style.display='inline'; Codehighlighter1_638_1067_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_638_1067_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_638_1067_Closed_Text.style.display='none'; Codehighlighter1_638_1067_Open_Image.style.display='inline'; Codehighlighter1_638_1067_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> testCompare()</span>
						<span id="Codehighlighter1_638_1067_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_638_1067_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #008000">//</span>
								<span style="COLOR: #008000">it's equal because -127~127 are immutable objects</span>
								<span style="COLOR: #008000">
										<br />
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
								</span>
								<span style="COLOR: #000000">        Integer i </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        Integer i2 </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000">(i </span>
								<span style="COLOR: #000000">==</span>
								<span style="COLOR: #000000"> i2) System.out.println(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">1:Equal</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">else</span>
								<span style="COLOR: #000000"> System.out.println(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">1:Not Equal</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #008000">//</span>
								<span style="COLOR: #008000">it's not equal because j and j2 are different objects</span>
								<span style="COLOR: #008000">
										<br />
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
								</span>
								<span style="COLOR: #000000">        Integer j </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">200</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        Integer j2 </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000">200</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000">(j </span>
								<span style="COLOR: #000000">==</span>
								<span style="COLOR: #000000"> j2) System.out.println(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">200:Equal</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">else</span>
								<span style="COLOR: #000000"> System.out.println(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">200:Not Equal</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_1098_1327_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1098_1327_Open_Text.style.display='none'; Codehighlighter1_1098_1327_Closed_Image.style.display='inline'; Codehighlighter1_1098_1327_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_1098_1327_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1098_1327_Closed_Text.style.display='none'; Codehighlighter1_1098_1327_Open_Image.style.display='inline'; Codehighlighter1_1098_1327_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> testControl()</span>
						<span id="Codehighlighter1_1098_1327_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_1098_1327_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        Boolean flag </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">true</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        Integer i </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">20</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        Integer j </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">30</span>
								<span style="COLOR: #000000">;<br /><img id="Codehighlighter1_1193_1254_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1193_1254_Open_Text.style.display='none'; Codehighlighter1_1193_1254_Closed_Image.style.display='inline'; Codehighlighter1_1193_1254_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_1193_1254_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1193_1254_Closed_Text.style.display='none'; Codehighlighter1_1193_1254_Open_Image.style.display='inline'; Codehighlighter1_1193_1254_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000">(flag)</span>
								<span id="Codehighlighter1_1193_1254_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.blogjava.net/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_1193_1254_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            System.out.println(</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">Boolean affects</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000">(i</span>
								<span style="COLOR: #000000">&lt;</span>
								<span style="COLOR: #000000">j)<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            System.out.println(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">Integer affects</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_1367_1450_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1367_1450_Open_Text.style.display='none'; Codehighlighter1_1367_1450_Closed_Image.style.display='inline'; Codehighlighter1_1367_1450_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_1367_1450_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1367_1450_Closed_Text.style.display='none'; Codehighlighter1_1367_1450_Open_Image.style.display='inline'; Codehighlighter1_1367_1450_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> testMethod(</span>
						<span style="COLOR: #0000ff">double</span>
						<span style="COLOR: #000000"> arg)</span>
						<span id="Codehighlighter1_1367_1450_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_1367_1450_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        System.out.println(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">public void testMethod(double arg) is invoked</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_1491_1576_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1491_1576_Open_Text.style.display='none'; Codehighlighter1_1491_1576_Closed_Image.style.display='inline'; Codehighlighter1_1491_1576_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_1491_1576_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1491_1576_Closed_Text.style.display='none'; Codehighlighter1_1491_1576_Open_Image.style.display='inline'; Codehighlighter1_1491_1576_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> testMethod(Integer arg)</span>
						<span id="Codehighlighter1_1491_1576_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_1491_1576_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        System.out.println(</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">public void testMethod2(Integer arg) is invoked</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_1620_2030_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1620_2030_Open_Text.style.display='none'; Codehighlighter1_1620_2030_Closed_Image.style.display='inline'; Codehighlighter1_1620_2030_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_1620_2030_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1620_2030_Closed_Text.style.display='none'; Codehighlighter1_1620_2030_Open_Image.style.display='inline'; Codehighlighter1_1620_2030_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">static</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> main(String args[])</span>
						<span id="Codehighlighter1_1620_2030_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_1620_2030_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        AutoBoxing auto </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">new</span>
								<span style="COLOR: #000000"> AutoBoxing();<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        auto.testCompare();<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        auto.testOperator();<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        auto.testControl();<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">int</span>
								<span style="COLOR: #000000"> i </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #000000">1</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #008000">//</span>
								<span style="COLOR: #008000"> public void testMethod(Integer arg) wouldn't be invoked<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #008000">//</span>
								<span style="COLOR: #008000">because  public void testMethod(double arg) will be invoked in JDK1.4<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #008000">//</span>
								<span style="COLOR: #008000">Java tiger consider the backward capability</span>
								<span style="COLOR: #008000">
										<br />
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />
								</span>
								<span style="COLOR: #000000">        auto.testMethod(i);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        auto.boxingDemo();<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
<img src ="http://www.blogjava.net/blueoxygen/aggbug/54554.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/blueoxygen/" target="_blank">BlueO2</a> 2006-06-22 18:34 <a href="http://www.blogjava.net/blueoxygen/archive/2006/06/22/54554.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>从code学习java tiger 之 枚举</title><link>http://www.blogjava.net/blueoxygen/archive/2006/06/22/54550.html</link><dc:creator>BlueO2</dc:creator><author>BlueO2</author><pubDate>Thu, 22 Jun 2006 10:22:00 GMT</pubDate><guid>http://www.blogjava.net/blueoxygen/archive/2006/06/22/54550.html</guid><wfw:comment>http://www.blogjava.net/blueoxygen/comments/54550.html</wfw:comment><comments>http://www.blogjava.net/blueoxygen/archive/2006/06/22/54550.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/blueoxygen/comments/commentRss/54550.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/blueoxygen/services/trackbacks/54550.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img id="Codehighlighter1_17_51_Open_Image" onclick="this.style.display='none'; Codehighlighter1_17_51_Open_Text.style.display='none'; Codehighlighter1_17_51_Closed_Image.style.display='inline'; Codehighlighter1_17_51_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
				<img id="Codehighlighter1_17_51_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_17_51_Closed_Text.style.display='none'; Codehighlighter1_17_51_Open_Image.style.display='inline'; Codehighlighter1_17_51_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">enum</span>
				<span style="COLOR: #000000"> User </span>
				<span id="Codehighlighter1_17_51_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.blogjava.net/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_17_51_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    Admin,User,Guest,Unknown   <br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
		<br />
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<img id="Codehighlighter1_19_1262_Open_Image" onclick="this.style.display='none'; Codehighlighter1_19_1262_Open_Text.style.display='none'; Codehighlighter1_19_1262_Closed_Image.style.display='inline'; Codehighlighter1_19_1262_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
				<img id="Codehighlighter1_19_1262_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_19_1262_Closed_Text.style.display='none'; Codehighlighter1_19_1262_Open_Image.style.display='inline'; Codehighlighter1_19_1262_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedBlock.gif" align="top" />
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000"> Login </span>
				<span id="Codehighlighter1_19_1262_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
						<img src="http://www.blogjava.net/images/dot.gif" />
				</span>
				<span id="Codehighlighter1_19_1262_Open_Text">
						<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">private</span>
						<span style="COLOR: #000000"> User user;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    EnumMap</span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000">User,String</span>
						<span style="COLOR: #000000">&gt;</span>
						<span style="COLOR: #000000"> userName </span>
						<span style="COLOR: #000000">=</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">new</span>
						<span style="COLOR: #000000"> EnumMap</span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000">User, String</span>
						<span style="COLOR: #000000">&gt;</span>
						<span style="COLOR: #000000">(User.</span>
						<span style="COLOR: #0000ff">class</span>
						<span style="COLOR: #000000">);<br /><img id="Codehighlighter1_128_165_Open_Image" onclick="this.style.display='none'; Codehighlighter1_128_165_Open_Text.style.display='none'; Codehighlighter1_128_165_Closed_Image.style.display='inline'; Codehighlighter1_128_165_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_128_165_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_128_165_Closed_Text.style.display='none'; Codehighlighter1_128_165_Open_Image.style.display='inline'; Codehighlighter1_128_165_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span id="Codehighlighter1_128_165_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/** */</span>
						<span id="Codehighlighter1_128_165_Open_Text">
								<span style="COLOR: #008000">/**</span>
								<span style="COLOR: #008000"> Creates a new instance of Login </span>
								<span style="COLOR: #008000">*/</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_186_328_Open_Image" onclick="this.style.display='none'; Codehighlighter1_186_328_Open_Text.style.display='none'; Codehighlighter1_186_328_Closed_Image.style.display='inline'; Codehighlighter1_186_328_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_186_328_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_186_328_Closed_Text.style.display='none'; Codehighlighter1_186_328_Open_Image.style.display='inline'; Codehighlighter1_186_328_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> Login() </span>
						<span id="Codehighlighter1_186_328_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_186_328_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        userName.put(User.Admin, </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">Administrator</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        userName.put(User.User, </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">David</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        userName.put(User.Guest, </span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">Steve</span>
								<span style="COLOR: #000000">"</span>
								<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_367_467_Open_Image" onclick="this.style.display='none'; Codehighlighter1_367_467_Open_Text.style.display='none'; Codehighlighter1_367_467_Closed_Image.style.display='inline'; Codehighlighter1_367_467_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_367_467_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_367_467_Closed_Text.style.display='none'; Codehighlighter1_367_467_Open_Image.style.display='inline'; Codehighlighter1_367_467_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">boolean</span>
						<span style="COLOR: #000000"> isAdmin(User user)</span>
						<span id="Codehighlighter1_367_467_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_367_467_Open_Text">
								<span style="COLOR: #000000">{<br /><img id="Codehighlighter1_404_439_Open_Image" onclick="this.style.display='none'; Codehighlighter1_404_439_Open_Text.style.display='none'; Codehighlighter1_404_439_Closed_Image.style.display='inline'; Codehighlighter1_404_439_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_404_439_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_404_439_Closed_Text.style.display='none'; Codehighlighter1_404_439_Open_Image.style.display='inline'; Codehighlighter1_404_439_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">if</span>
								<span style="COLOR: #000000">(user.equals(User.Admin))</span>
								<span id="Codehighlighter1_404_439_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.blogjava.net/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_404_439_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">return</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #0000ff">true</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">return</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">false</span>
								<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_500_637_Open_Image" onclick="this.style.display='none'; Codehighlighter1_500_637_Open_Text.style.display='none'; Codehighlighter1_500_637_Closed_Image.style.display='inline'; Codehighlighter1_500_637_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_500_637_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_500_637_Closed_Text.style.display='none'; Codehighlighter1_500_637_Open_Image.style.display='inline'; Codehighlighter1_500_637_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> printUserRole()</span>
						<span id="Codehighlighter1_500_637_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_500_637_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        User[] users </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> user.values();<br /><img id="Codehighlighter1_575_631_Open_Image" onclick="this.style.display='none'; Codehighlighter1_575_631_Open_Text.style.display='none'; Codehighlighter1_575_631_Closed_Image.style.display='inline'; Codehighlighter1_575_631_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_575_631_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_575_631_Closed_Text.style.display='none'; Codehighlighter1_575_631_Open_Image.style.display='inline'; Codehighlighter1_575_631_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">for</span>
								<span style="COLOR: #000000">(User u : user.values())</span>
								<span id="Codehighlighter1_575_631_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.blogjava.net/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_575_631_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            System.out.println(u.toString());<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_672_1051_Open_Image" onclick="this.style.display='none'; Codehighlighter1_672_1051_Open_Text.style.display='none'; Codehighlighter1_672_1051_Closed_Image.style.display='inline'; Codehighlighter1_672_1051_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_672_1051_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_672_1051_Closed_Text.style.display='none'; Codehighlighter1_672_1051_Open_Image.style.display='inline'; Codehighlighter1_672_1051_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> isRole(User user)</span>
						<span id="Codehighlighter1_672_1051_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_672_1051_Open_Text">
								<span style="COLOR: #000000">{<br /><img id="Codehighlighter1_694_1045_Open_Image" onclick="this.style.display='none'; Codehighlighter1_694_1045_Open_Text.style.display='none'; Codehighlighter1_694_1045_Closed_Image.style.display='inline'; Codehighlighter1_694_1045_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="Codehighlighter1_694_1045_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_694_1045_Closed_Text.style.display='none'; Codehighlighter1_694_1045_Open_Image.style.display='inline'; Codehighlighter1_694_1045_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />        </span>
								<span style="COLOR: #0000ff">switch</span>
								<span style="COLOR: #000000">(user)</span>
								<span id="Codehighlighter1_694_1045_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
										<img src="http://www.blogjava.net/images/dot.gif" />
								</span>
								<span id="Codehighlighter1_694_1045_Open_Text">
										<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">case</span>
										<span style="COLOR: #000000"> Admin:<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />                System.out.println(</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">admin</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
										<span style="COLOR: #0000ff">break</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">case</span>
										<span style="COLOR: #000000"> User:<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />                System.out.println(</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">User</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
										<span style="COLOR: #0000ff">break</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">case</span>
										<span style="COLOR: #000000"> Guest:<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />                System.out.println(</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">Guest</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />                </span>
										<span style="COLOR: #0000ff">break</span>
										<span style="COLOR: #000000">;<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />            </span>
										<span style="COLOR: #0000ff">default</span>
										<span style="COLOR: #000000">:<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />                System.out.println(</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">unknow</span>
										<span style="COLOR: #000000">"</span>
										<span style="COLOR: #000000">);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />        }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img id="Codehighlighter1_1095_1255_Open_Image" onclick="this.style.display='none'; Codehighlighter1_1095_1255_Open_Text.style.display='none'; Codehighlighter1_1095_1255_Closed_Image.style.display='inline'; Codehighlighter1_1095_1255_Closed_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" />
								<img id="Codehighlighter1_1095_1255_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1095_1255_Closed_Text.style.display='none'; Codehighlighter1_1095_1255_Open_Image.style.display='inline'; Codehighlighter1_1095_1255_Open_Text.style.display='inline';" src="http://www.blogjava.net/images/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">static</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #0000ff">void</span>
						<span style="COLOR: #000000"> main(String[] args)</span>
						<span id="Codehighlighter1_1095_1255_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">
								<img src="http://www.blogjava.net/images/dot.gif" />
						</span>
						<span id="Codehighlighter1_1095_1255_Open_Text">
								<span style="COLOR: #000000">{<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        Login login </span>
								<span style="COLOR: #000000">=</span>
								<span style="COLOR: #000000"> </span>
								<span style="COLOR: #0000ff">new</span>
								<span style="COLOR: #000000"> Login();<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        System.out.println(login.isAdmin(User.Admin));<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        login.printUserRole();<br /><img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />        login.isRole(User.User);<br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img src="http://www.blogjava.net/images/OutliningIndicators/InBlock.gif" align="top" />    <br /><img src="http://www.blogjava.net/images/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
				</span>
		</div>
<img src ="http://www.blogjava.net/blueoxygen/aggbug/54550.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/blueoxygen/" target="_blank">BlueO2</a> 2006-06-22 18:22 <a href="http://www.blogjava.net/blueoxygen/archive/2006/06/22/54550.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>从codes学java tiger之范型</title><link>http://www.blogjava.net/blueoxygen/archive/2006/06/20/54045.html</link><dc:creator>BlueO2</dc:creator><author>BlueO2</author><pubDate>Tue, 20 Jun 2006 10:18:00 GMT</pubDate><guid>http://www.blogjava.net/blueoxygen/archive/2006/06/20/54045.html</guid><wfw:comment>http://www.blogjava.net/blueoxygen/comments/54045.html</wfw:comment><comments>http://www.blogjava.net/blueoxygen/archive/2006/06/20/54045.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/blueoxygen/comments/commentRss/54045.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/blueoxygen/services/trackbacks/54045.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: public				 				class				 Generic 																								{        						/** */														/**								 Creates a new instance of Generic 								*/																				...&nbsp;&nbsp;<a href='http://www.blogjava.net/blueoxygen/archive/2006/06/20/54045.html'>阅读全文</a><img src ="http://www.blogjava.net/blueoxygen/aggbug/54045.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/blueoxygen/" target="_blank">BlueO2</a> 2006-06-20 18:18 <a href="http://www.blogjava.net/blueoxygen/archive/2006/06/20/54045.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>斗胆给Thinking in JAVA挑错</title><link>http://www.blogjava.net/blueoxygen/archive/2005/10/08/14977.html</link><dc:creator>BlueO2</dc:creator><author>BlueO2</author><pubDate>Sat, 08 Oct 2005 04:05:00 GMT</pubDate><guid>http://www.blogjava.net/blueoxygen/archive/2005/10/08/14977.html</guid><wfw:comment>http://www.blogjava.net/blueoxygen/comments/14977.html</wfw:comment><comments>http://www.blogjava.net/blueoxygen/archive/2005/10/08/14977.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/blueoxygen/comments/commentRss/14977.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/blueoxygen/services/trackbacks/14977.html</trackback:ping><description><![CDATA[<DIV>今天晚上被讨厌的vba郁闷，以后谁再跟我说vb简单易用我跟谁急。由于计划上每天都要继续讨论java基础语言特性，所以最近也返璞归真，重读thinking in java。发现了一个问题如下：</DIV>
<DIV>在第9章 持有你的对象arrays的比较章节，有如此代码片断：<BR>String[] s1 = new String[5];<BR>Arrays.fill(s1,"hi");<BR>String[] s2 = {"hi","hi","hi","hi","hi"};<BR>System.out.println(Arrays.equals(s1,s2));<BR>输出结果true<BR>Bruce给出的解释是s1的所有元素指向同一个对象，s2却拥有5个不同对象，但是Arrays.equals比较的是内容，还特意强调通过Object.equals()，所以结果为true.<BR>首先，我们看看Arryas.fill(s1,"hi")如何工作：<BR>SRC:<BR>public static void fill(Object[] a, Object val) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fill(a, 0, a.length, val);<BR>&nbsp;&nbsp;&nbsp; }<BR>public static void fill(Object[] a, int fromIndex, int toIndex,Object val){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rangeCheck(a.length, fromIndex, toIndex);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int i=fromIndex; i&lt;toIndex; i++)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a[i] = val;<BR>&nbsp;&nbsp;&nbsp; }</DIV>
<DIV>显然所有的s1中原素指向了相同的一个对象"hi"这里Bruce没错，那么后面的s2是否拥有5个不同的对象呢？我们做以下代码测试(其中捎带着String类型的测试)<BR><FONT color=#a1a100><SPAN>import java.util.Arrays;</SPAN><BR></FONT><SPAN><STRONG><FONT color=#000000>public</FONT></STRONG></SPAN> <SPAN><STRONG><FONT color=#000000>class</FONT></STRONG></SPAN> profit<FONT color=#66cc66><SPAN>{</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; <SPAN><STRONG><FONT color=#000000>public</FONT></STRONG></SPAN> <SPAN><FONT color=#993333>static</FONT></SPAN> <SPAN><FONT color=#993333>void</FONT></SPAN> main<SPAN><FONT color=#66cc66>(</FONT></SPAN><A href="http://www.google.com/search?q=allinurl:String+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>String</FONT></U></STRONG></SPAN></A> args<FONT color=#66cc66><SPAN>[</SPAN><SPAN>]</SPAN><SPAN>)</SPAN><SPAN>{</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <A href="http://www.google.com/search?q=allinurl:String+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>String</FONT></U></STRONG></SPAN></A> s1 = <SPAN><FONT color=#ff0000>"Hi"</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <A href="http://www.google.com/search?q=allinurl:String+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>String</FONT></U></STRONG></SPAN></A> s2 = <SPAN><FONT color=#ff0000>"Hi"</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <A href="http://www.google.com/search?q=allinurl:String+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>String</FONT></U></STRONG></SPAN></A> s3 = <SPAN><STRONG><FONT color=#000000>new</FONT></STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl:String+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>String</FONT></U></STRONG></SPAN></A><SPAN><FONT color=#66cc66>(</FONT></SPAN><SPAN><FONT color=#ff0000>"Hi"</FONT></SPAN><SPAN><FONT color=#66cc66>)</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <A href="http://www.google.com/search?q=allinurl:String+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>String</FONT></U></STRONG></SPAN></A> s4 = <SPAN><STRONG><FONT color=#000000>new</FONT></STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl:String+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>String</FONT></U></STRONG></SPAN></A><SPAN><FONT color=#66cc66>(</FONT></SPAN><SPAN><FONT color=#ff0000>"Hi"</FONT></SPAN><SPAN><FONT color=#66cc66>)</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN><FONT color=#b1b100>if</FONT></SPAN><SPAN><FONT color=#66cc66>(</FONT></SPAN>s1==s2<SPAN><FONT color=#66cc66>)</FONT></SPAN> <A href="http://www.google.com/search?q=allinurl:System+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>System</FONT></U></STRONG></SPAN></A>.<SPAN><FONT color=#006600>out</FONT></SPAN>.<SPAN><FONT color=#006600>println</FONT></SPAN><SPAN><FONT color=#66cc66>(</FONT></SPAN><SPAN><FONT color=#ff0000>"s1 s2 equal"</FONT></SPAN><SPAN><FONT color=#66cc66>)</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN><FONT color=#b1b100>if</FONT></SPAN><SPAN><FONT color=#66cc66>(</FONT></SPAN>s3==s4<SPAN><FONT color=#66cc66>)</FONT></SPAN> <A href="http://www.google.com/search?q=allinurl:System+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>System</FONT></U></STRONG></SPAN></A>.<SPAN><FONT color=#006600>out</FONT></SPAN>.<SPAN><FONT color=#006600>println</FONT></SPAN><SPAN><FONT color=#66cc66>(</FONT></SPAN><SPAN><FONT color=#ff0000>"s3 s4 equal"</FONT></SPAN><SPAN><FONT color=#66cc66>)</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#808080><SPAN>//System.out.println(s3.hashCode());</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <FONT color=#808080><SPAN>//System.out.println(s4.hashCode());</SPAN><BR></FONT>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <A href="http://www.google.com/search?q=allinurl:String+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>String</FONT></U></STRONG></SPAN></A><FONT color=#66cc66><SPAN>[</SPAN><SPAN>]</SPAN></FONT> strArray = <SPAN><STRONG><FONT color=#000000>new</FONT></STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl:String+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>String</FONT></U></STRONG></SPAN></A><SPAN><FONT color=#66cc66>[</FONT></SPAN><SPAN><FONT color=#cc66cc>2</FONT></SPAN><SPAN><FONT color=#66cc66>]</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <A href="http://www.google.com/search?q=allinurl:Arrays+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>Arrays</FONT></U></STRONG></SPAN></A>.<SPAN><FONT color=#006600>fill</FONT></SPAN><SPAN><FONT color=#66cc66>(</FONT></SPAN>strArray,<SPAN><FONT color=#ff0000>"hello"</FONT></SPAN><SPAN><FONT color=#66cc66>)</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN><FONT color=#b1b100>if</FONT></SPAN><SPAN><FONT color=#66cc66>(</FONT></SPAN>strArray<SPAN><FONT color=#66cc66>[</FONT></SPAN><SPAN><FONT color=#cc66cc>0</FONT></SPAN><SPAN><FONT color=#66cc66>]</FONT></SPAN>==strArray<SPAN><FONT color=#66cc66>[</FONT></SPAN><SPAN><FONT color=#cc66cc>1</FONT></SPAN><FONT color=#66cc66><SPAN>]</SPAN><SPAN>)</SPAN></FONT> <A href="http://www.google.com/search?q=allinurl:System+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>System</FONT></U></STRONG></SPAN></A>.<SPAN><FONT color=#006600>out</FONT></SPAN>.<SPAN><FONT color=#006600>println</FONT></SPAN><SPAN><FONT color=#66cc66>(</FONT></SPAN><SPAN><FONT color=#ff0000>"strArray equal"</FONT></SPAN><SPAN><FONT color=#66cc66>)</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <A href="http://www.google.com/search?q=allinurl:String+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>String</FONT></U></STRONG></SPAN></A><FONT color=#66cc66><SPAN>[</SPAN><SPAN>]</SPAN></FONT> strArray2 = <SPAN><FONT color=#66cc66>{</FONT></SPAN><SPAN><FONT color=#ff0000>"hello"</FONT></SPAN>,<SPAN><FONT color=#ff0000>"hello"</FONT></SPAN><SPAN><FONT color=#66cc66>}</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN><FONT color=#b1b100>if</FONT></SPAN><SPAN><FONT color=#66cc66>(</FONT></SPAN>strArray2<SPAN><FONT color=#66cc66>[</FONT></SPAN><SPAN><FONT color=#cc66cc>0</FONT></SPAN><SPAN><FONT color=#66cc66>]</FONT></SPAN>==strArray2<SPAN><FONT color=#66cc66>[</FONT></SPAN><SPAN><FONT color=#cc66cc>1</FONT></SPAN><FONT color=#66cc66><SPAN>]</SPAN><SPAN>)</SPAN></FONT> <A href="http://www.google.com/search?q=allinurl:System+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>System</FONT></U></STRONG></SPAN></A>.<SPAN><FONT color=#006600>out</FONT></SPAN>.<SPAN><FONT color=#006600>println</FONT></SPAN><SPAN><FONT color=#66cc66>(</FONT></SPAN><SPAN><FONT color=#ff0000>"strArray2 equal"</FONT></SPAN><SPAN><FONT color=#66cc66>)</FONT></SPAN>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <A href="http://www.google.com/search?q=allinurl:String+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>String</FONT></U></STRONG></SPAN></A><FONT color=#66cc66><SPAN>[</SPAN><SPAN>]</SPAN></FONT> strArray3 = <SPAN><FONT color=#66cc66>{</FONT></SPAN><SPAN><STRONG><FONT color=#000000>new</FONT></STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl:String+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>String</FONT></U></STRONG></SPAN></A><SPAN><FONT color=#66cc66>(</FONT></SPAN><SPAN><FONT color=#ff0000>"hello"</FONT></SPAN><SPAN><FONT color=#66cc66>)</FONT></SPAN>,<SPAN><STRONG><FONT color=#000000>new</FONT></STRONG></SPAN> <A href="http://www.google.com/search?q=allinurl:String+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>String</FONT></U></STRONG></SPAN></A><SPAN><FONT color=#66cc66>(</FONT></SPAN><SPAN><FONT color=#ff0000>"hello"</FONT></SPAN><FONT color=#66cc66><SPAN>)</SPAN><SPAN>}</SPAN></FONT>;<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <SPAN><FONT color=#b1b100>if</FONT></SPAN><SPAN><FONT color=#66cc66>(</FONT></SPAN>strArray3<SPAN><FONT color=#66cc66>[</FONT></SPAN><SPAN><FONT color=#cc66cc>0</FONT></SPAN><SPAN><FONT color=#66cc66>]</FONT></SPAN>==strArray<SPAN><FONT color=#66cc66>[</FONT></SPAN><SPAN><FONT color=#cc66cc>1</FONT></SPAN><FONT color=#66cc66><SPAN>]</SPAN><SPAN>)</SPAN></FONT> <A href="http://www.google.com/search?q=allinurl:System+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>System</FONT></U></STRONG></SPAN></A>.<SPAN><FONT color=#006600>out</FONT></SPAN>.<SPAN><FONT color=#006600>println</FONT></SPAN><SPAN><FONT color=#66cc66>(</FONT></SPAN><SPAN><FONT color=#ff0000>"strArray3 equal"</FONT></SPAN><SPAN><FONT color=#66cc66>)</FONT></SPAN>;<BR></DIV>
<P>输出结果：<BR>---------- Run ----------<BR>s1 s2 equal<BR>strArray equal<BR>strArray2 equal</P>
<P>Output completed (1 sec consumed) - Normal Termination<BR>首先，各位应该明白最基础的东西 ==实现的比较是浅比较，就是非reference指向的具体对象内容，而是是否指向了同一个对象。第二，String类型被设计为非可变类，就是说 String s1 = "hi";与String s2 = "hi";其实指向了同一个对象，只有用new构造函数的时候才会产生新的对象，而不管内容是否已经在内存中存在。如下文字阐述了一些：<BR><FONT color=#800000>s = new String("Initial Value"); <BR>每次都会调用构造器，生成新对象，性能低下且内存开销大，并且没有意义，因为String对象不可改变，所以对于内容相同的字符串，只要一个String对象来表示就可以了。也就说，多次调用上面的构造器创建多个对象，他们的String类型属性s都指向同一个对象。 <BR>上面的结论还基于这样一个事实：对于字符串常量，如果内容相同，Java认为它们代表同一个String对象。而用关键字new调用构造器，总是会创建一个新的对象，无论内容是否相同<BR></FONT><FONT color=#000000>ok，回到</FONT>我们的话题上来String[] s2 = {"hi","hi","hi","hi","hi"};是否产生了5个不同的对象呢？我写的简单的测试代码</P>
<P><A href="http://www.google.com/search?q=allinurl:String+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>String</FONT></U></STRONG></SPAN></A><FONT color=#66cc66><SPAN>[</SPAN><SPAN>]</SPAN></FONT> strArray2 = <SPAN><FONT color=#66cc66>{</FONT></SPAN><SPAN><FONT color=#ff0000>"hello"</FONT></SPAN>,<SPAN><FONT color=#ff0000>"hello"</FONT></SPAN><SPAN><FONT color=#66cc66>}</FONT></SPAN>;<BR>&nbsp;<SPAN><FONT color=#b1b100>if</FONT></SPAN><SPAN><FONT color=#66cc66>(</FONT></SPAN>strArray2<SPAN><FONT color=#66cc66>[</FONT></SPAN><SPAN><FONT color=#cc66cc>0</FONT></SPAN><SPAN><FONT color=#66cc66>]</FONT></SPAN>==strArray2<SPAN><FONT color=#66cc66>[</FONT></SPAN><SPAN><FONT color=#cc66cc>1</FONT></SPAN><FONT color=#66cc66><SPAN>]</SPAN><SPAN>)</SPAN></FONT> <A href="http://www.google.com/search?q=allinurl:System+java.sun.com&amp;bntl=1"><SPAN><STRONG><U><FONT color=#aaaadd>System</FONT></U></STRONG></SPAN></A>.<SPAN><FONT color=#006600>out</FONT></SPAN>.<SPAN><FONT color=#006600>println</FONT></SPAN><SPAN><FONT color=#66cc66>(</FONT></SPAN><SPAN><FONT color=#ff0000>"strArray2 equal"</FONT></SPAN><SPAN><FONT color=#66cc66>)</FONT></SPAN>;<BR>的结果大家应该得出了结论了吧。<BR>那么，bruce给出的代码的结果之所以为true就是因为，这么多个数组中的成员"hi"其实都是同一个对象。那么我们继续看Arrays.equals是否比较的内容呢？<BR>SRC：<BR>public static boolean equals(Object[] a, Object[] a2) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (a==a2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return true;&nbsp;&nbsp; //如果指向同一对象，当然是相同的，返回true<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (a==null || a2==null)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;&nbsp; //如果为null就没有相等的一说，false</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int length = a.length;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (a2.length != length)&nbsp; //长度不同<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (int i=0; i&lt;length; i++) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object o1 = a[i];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object o2 = a2[i];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!(o1==null ? o2==null : o1.equals(o2)))&nbsp; //此处为关键，object的equals比较，Arrays.equals并没有专门为String类型重载此方法，全部都依赖Object的方法比较<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return false;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return true;<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>那么我们再看看Object这个树根的equals方法吧：<BR>public boolean equals(Object obj) {<BR>&nbsp;return (this == obj);<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>短短几行代码，但是，是浅比较毫无疑问，所以，bruce说的，依赖的是Object.equals，比较的是内容，更是错误的。<BR>但是必须强调的是，当String数组传递进来的时候，由于java的RTTI执行期型别辨识，Arryas.equals调用的其实是String.equals方法，而String.equals方法是比较内容的，所以，此处我想是bruce没有说明白，而又偏偏列举了String的例子。如果是自己写的类有没有复写equals方法，此时就调用Object.equals了，那么根本不可能比较内容，所以Arrays.equals大家一定要知道怎么回事再用。</P><img src ="http://www.blogjava.net/blueoxygen/aggbug/14977.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/blueoxygen/" target="_blank">BlueO2</a> 2005-10-08 12:05 <a href="http://www.blogjava.net/blueoxygen/archive/2005/10/08/14977.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>