<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Java人生</title>
	<atom:link href="http://www.sky45.tk/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.sky45.tk</link>
	<description>汇聚点滴，凝结智慧</description>
	<lastBuildDate>Sat, 22 Oct 2011 07:43:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>ClassLoader详解</title>
		<link>http://www.sky45.tk/?p=340</link>
		<comments>http://www.sky45.tk/?p=340#comments</comments>
		<pubDate>Sat, 22 Oct 2011 07:20:14 +0000</pubDate>
		<dc:creator>jame</dc:creator>
				<category><![CDATA[JVM深入]]></category>
		<category><![CDATA[ClassLoader]]></category>

		<guid isPermaLink="false">http://jlife.tk/?p=340</guid>
		<description><![CDATA[　　顾名思义，类加载器（class loader）用来加载 Java 类到 Java 虚拟机中。基本上所有的类加载器都是 java.lang.ClassLoader 类的一个实例。java.lang.ClassLoader 类的基本职责就是根据一个指定的类的名称，找到或者生成其对应的字节代码，然后从这些字节代码中定义出一个 Java 类，即 java.lang.Class 类的一个实例。除此之外，ClassLoader 还负责加载 Java 应用所需的资源，如图像文件和配置文件等。不过本文只讨论其加载类的功能。为了完成加载类的这个职责，ClassLoader 提供了一系列的方法. 类加载器的树状组织结构 　　Java 中的类加载器大致可以分成两类，一类是系统提供的，另外一类则是由 Java 应用开发人员编写的。系统提供的类加载器主要有下面三个： 　　引导类加载器（bootstrap class loader）：它用来加载 Java 的核心库，是用原生代码来实现的，并不继承自 java.lang.ClassLoader。 　　扩展类加载器（extensions class loader）：它用来加载 Java 的扩展库。Java 虚拟机的实现会提供一个扩展库目录。该类加载器在此目录里面查找并加载 Java 类。 　　系统类加载器（system class loader）：它根据 Java 应用的类路径（CLASSPATH）来加载 Java 类。一般来说，Java 应用的类都是由它来完成加载的。可以通过 ClassLoader.getSystemClassLoader() 来获取它。 　　除了系统提供的类加载器以外，开发人员可以通过继承 java.lang.ClassLoader 类的方式实现自己的类加载器，以满足一些特殊的需求。 　　除了引导类加载器之外，所有的类加载器都有一个父类加载器。通过ClassLoader类的 getParent() 方法可以得到。对于系统提供的类加载器来说，系统类加载器的父类加载器是扩展类加载器，而扩展类加载器的父类加载器是引导类加载器；对于开发人员编写的类加载器来说，其父类加载器是加载此类加载器 Java 类的类加载器。因为类加载器 Java [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="3"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="快速排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D98&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D340">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10022017.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">快速排序</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="直接插入排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D158&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D340">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021992.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">直接插入排序</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="希尔排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D93&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D340">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021996.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">希尔排序</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="3" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>　　顾名思义，类加载器（class loader）用来加载 Java 类到 Java 虚拟机中。基本上所有的类加载器都是 java.lang.ClassLoader 类的一个实例。java.lang.ClassLoader 类的基本职责就是根据一个指定的类的名称，找到或者生成其对应的字节代码，然后从这些字节代码中定义出一个 Java 类，即 java.lang.Class 类的一个实例。除此之外，ClassLoader 还负责加载 Java 应用所需的资源，如图像文件和配置文件等。不过本文只讨论其加载类的功能。为了完成加载类的这个职责，ClassLoader 提供了一系列的方法.<br />
<span id="more-340"></span><br />
类加载器的树状组织结构<br />
　　Java 中的类加载器大致可以分成两类，一类是系统提供的，另外一类则是由 Java 应用开发人员编写的。系统提供的类加载器主要有下面三个：<br />
　　引导类加载器（bootstrap class loader）：它用来加载 Java 的核心库，是用原生代码来实现的，并不继承自 java.lang.ClassLoader。<br />
　　扩展类加载器（extensions class loader）：它用来加载 Java 的扩展库。Java 虚拟机的实现会提供一个扩展库目录。该类加载器在此目录里面查找并加载 Java 类。<br />
　　系统类加载器（system class loader）：它根据 Java 应用的类路径（CLASSPATH）来加载 Java 类。一般来说，Java 应用的类都是由它来完成加载的。可以通过 ClassLoader.getSystemClassLoader() 来获取它。<br />
　　除了系统提供的类加载器以外，开发人员可以通过继承 java.lang.ClassLoader 类的方式实现自己的类加载器，以满足一些特殊的需求。<br />
　　除了引导类加载器之外，所有的类加载器都有一个父类加载器。通过ClassLoader类的 getParent() 方法可以得到。对于系统提供的类加载器来说，系统类加载器的父类加载器是扩展类加载器，而扩展类加载器的父类加载器是引导类加载器；对于开发人员编写的类加载器来说，其父类加载器是加载此类加载器 Java 类的类加载器。因为类加载器 Java 类如同其它的 Java 类一样，也是要由类加载器来加载的。一般来说，开发人员编写的类加载器的父类加载器是系统类加载器。类加载器通过这种方式组织起来，形成树状结构。树的根节点就是引导类加载器</p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ClassLoaderTree<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aclassloader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">ClassLoader</span></a> loader <span style="color: #339933;">=</span> ClassLoaderTree.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getClassLoader</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>loader<span style="color: #339933;">!=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>loader.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; loader <span style="color: #339933;">=</span> loader.<span style="color: #006633;">getParent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
输出：<br />
sun.<span style="color: #006633;">misc</span>.<span style="color: #006633;">Launcher</span>$AppClassLoader@addbf1<br />
sun.<span style="color: #006633;">misc</span>.<span style="color: #006633;">Launcher</span>$ExtClassLoader@42e816</div></td></tr></tbody></table></div>
<p>体系结构：<br />
    Bootstrap ClassLoader/启动类加载器<br />
    主要负责jdk_home/lib目录下的核心 api 或 -Xbootclasspath 选项指定的jar包装入工作。<br />
    Extension ClassLoader/扩展类加载器<br />
    主要负责jdk_home/lib/ext目录下的jar包或 -Djava.ext.dirs 指定目录下的jar包装入工作。<br />
    System ClassLoader/系统类加载器<br />
    主要负责java -classpath/-Djava.class.path所指的目录下的类与jar包装入工作。<br />
    User Custom ClassLoader/用户自定义类加载器(java.lang.ClassLoader的子类)<br />
    在程序运行期间, 通过java.lang.ClassLoader的子类动态加载class文件, 体现java动态实时类装入特性。<br />
<a href="http://jlife.tk/files/2011/10/classloader-load-class.jpg"><img src="http://jlife.tk/files/2011/10/classloader-load-class.jpg" alt="" width="583" height="289" class="aligncenter size-full wp-image-343" /></a></p>
<p>ClassLoader 类加载逻辑分析， 以下逻辑是除 BootstrapClassLoader 外的类加载器加载流程：</p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// 检查类是否已被装载过 &nbsp;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">Class</span> c <span style="color: #339933;">=</span> findLoadedClass<span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// 指定类未被装载过 &nbsp;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>parent <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// 如果父类加载器不为空， 则委派给父类加载 &nbsp;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;c <span style="color: #339933;">=</span> parent.<span style="color: #006633;">loadClass</span><span style="color: #009900;">&#40;</span>name, <span style="color: #000066; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// 如果父类加载器为空， 则委派给启动类加载加载 &nbsp;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;c <span style="color: #339933;">=</span> findBootstrapClass0<span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aclassnotfoundexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">ClassNotFoundException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// 启动类加载器或父类加载器抛出异常后， 当前类加载器将其 &nbsp;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// 捕获， 并通过findClass方法， 由自身加载 &nbsp;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;c <span style="color: #339933;">=</span> findClass<span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span> &nbsp;<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="3"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="希尔排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D93&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D340">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021996.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">希尔排序</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="快速排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D98&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D340">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10022017.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">快速排序</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="直接插入排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D158&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D340">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021992.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">直接插入排序</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="3" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.sky45.tk/?feed=rss2&#038;p=340</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java参数传递的两种方式</title>
		<link>http://www.sky45.tk/?p=338</link>
		<comments>http://www.sky45.tk/?p=338#comments</comments>
		<pubDate>Sun, 16 Oct 2011 02:30:34 +0000</pubDate>
		<dc:creator>jame</dc:creator>
				<category><![CDATA[Java小知识]]></category>
		<category><![CDATA[参数传递]]></category>
		<category><![CDATA[对象引用]]></category>

		<guid isPermaLink="false">http://jlife.tk/?p=338</guid>
		<description><![CDATA[首先，Java中传递参数的有传值和传引用两种方式。 对于原始数据类型(原生类)，也就是int、long、char等类型，参数传递是传值的。开发者在方法中修改了参数值，方法调用结束后，那个变量的值并没有发生改变。也就是说，在参数传递的过程中，该变量的值在方法调用期间会复制给形参。因为形参是方法的局部变量，所以对形参做出的任何修改在调用结束都不会影响该变量的值。 如果传递的是指向对象的引用，那么就会传递引用值。这意味着，在方法调用期间，实参和形参都是该引用值所代表对象的别名，对形参的修改就会导致实参的修改，而数组就是作为对象引用值来传递的 12345678class test&#123; &#160; &#160; public static void main&#40;String&#91;&#93; args&#41;&#123; &#160; &#160; &#160; &#160; int&#91;&#93;x&#91;&#93; = &#123;&#123;1,2&#125;,&#123;3,4,5&#125;,&#123;6,7,8,9&#125;&#125;; &#160; &#160; &#160; &#160; int&#91;&#93;&#91;&#93;y = x; &#160; &#160; &#160; &#160; y&#91;2&#93;&#91;1&#93; = 6; &#160; &#160; &#160; &#160; System.out.print&#40;x&#91;2&#93;&#91;1&#93;&#41;; &#160; &#160; &#125; &#125; 因此，上面的例子就是输出6，而不是7 另外，再看一道SCJP的题： 12345678910111213141516171819Given: class Batman&#123; &#160; &#160;int squares = 81; &#160; &#160;public static [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D57&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D338">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">对象引用例子</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D88&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D338">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">对象创建的初始化过程</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D331&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D338">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">广州从兴电子开发2012校园招聘笔试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D121&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D338">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">控制台输入的两种方法</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>首先，Java中传递参数的有传值和传引用两种方式。<br />
对于原始数据类型(原生类)，也就是int、long、char等类型，参数传递是传值的。开发者在方法中修改了参数值，方法调用结束后，那个变量的值并没有发生改变。也就是说，在参数传递的过程中，该变量的值在方法调用期间会复制给形参。因为形参是方法的局部变量，所以对形参做出的任何修改在调用结束都不会影响该变量的值。<br />
<span id="more-338"></span><br />
	如果传递的是指向对象的引用，那么就会传递引用值。这意味着，在方法调用期间，实参和形参都是该引用值所代表对象的别名，对形参的修改就会导致实参的修改，而数组就是作为对象引用值来传递的</p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">class</span> test<span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span>x<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span>,<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">3</span>,<span style="color: #cc66cc;">4</span>,<span style="color: #cc66cc;">5</span><span style="color: #009900;">&#125;</span>,<span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">6</span>,<span style="color: #cc66cc;">7</span>,<span style="color: #cc66cc;">8</span>,<span style="color: #cc66cc;">9</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span>y <span style="color: #339933;">=</span> x<span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; y<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>因此，上面的例子就是输出6，而不是7<br />
另外，再看一道SCJP的题：</p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Given<span style="color: #339933;">:</span> <br />
<span style="color: #000000; font-weight: bold;">class</span> Batman<span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">int</span> squares <span style="color: #339933;">=</span> <span style="color: #cc66cc;">81</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">new</span> Batman<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">go</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span> <br />
&nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">void</span> go<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; incr<span style="color: #009900;">&#40;</span><span style="color: #339933;">++</span>squares<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>squares<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span> <br />
&nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">void</span> incr<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> squares<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>squares <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> <br />
<span style="color: #009900;">&#125;</span> <br />
What is the result<span style="color: #339933;">?</span><br />
A. &nbsp;<span style="color: #cc66cc;">81</span> <br />
B. &nbsp;<span style="color: #cc66cc;">82</span> <br />
C. &nbsp;<span style="color: #cc66cc;">91</span> <br />
D. &nbsp;<span style="color: #cc66cc;">92</span> <br />
E. &nbsp;<span style="color: #006633;">Compilation</span> fails. <br />
<span style="color: #006633;">F</span>. &nbsp;<span style="color: #006633;">An</span> exception is thrown at runtime.</div></td></tr></tbody></table></div>
<p>输出的是82，而不是92，因为int类型是传值</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D57&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D338">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">对象引用例子</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D88&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D338">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">对象创建的初始化过程</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D331&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D338">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">广州从兴电子开发2012校园招聘笔试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D121&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D338">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">控制台输入的两种方法</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.sky45.tk/?feed=rss2&#038;p=338</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>属性覆盖问题</title>
		<link>http://www.sky45.tk/?p=336</link>
		<comments>http://www.sky45.tk/?p=336#comments</comments>
		<pubDate>Sun, 16 Oct 2011 02:24:52 +0000</pubDate>
		<dc:creator>jame</dc:creator>
				<category><![CDATA[Java小知识]]></category>
		<category><![CDATA[属性覆盖]]></category>

		<guid isPermaLink="false">http://jlife.tk/?p=336</guid>
		<description><![CDATA[在Java中，对于方法覆盖，那是很常见的，但对于属性覆盖呢？其实也是很常见的，只是我们没有加以注意而已，本文就过去对属性覆盖的各种问题的验证结果写到这里，希望能给有需要的朋友一点帮助。首先我们来看一道SCJP考试的题目： 1234567891011121314151617181920212223class Foo &#123; &#160; &#160; public int a = 3; &#160; &#160; public void addFive&#40;&#41; &#123; a += 5; System.out.print&#40;&#34;f &#34;&#41;; &#125; &#125; class Bar extends Foo &#123; &#160; &#160; public int a = 8; &#160; &#160; public void addFive&#40;&#41; &#123; this.a += 5; System.out.print&#40;&#34;b &#34; &#41;; &#125; &#125; Invoked with: Foo f = [...]<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="ClassLoader详解" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D340&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D336">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021807.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">ClassLoader详解</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="快速排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D98&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D336">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10022017.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">快速排序</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="直接插入排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D158&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D336">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021992.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">直接插入排序</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="希尔排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D93&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D336">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021996.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">希尔排序</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>在Java中，对于方法覆盖，那是很常见的，但对于属性覆盖呢？其实也是很常见的，只是我们没有加以注意而已，本文就过去对属性覆盖的各种问题的验证结果写到这里，希望能给有需要的朋友一点帮助。首先我们来看一道SCJP考试的题目：<br />
<span id="more-336"></span></p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">class</span> Foo <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> a <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> addFive<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> a <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;f &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">class</span> Bar <span style="color: #000000; font-weight: bold;">extends</span> Foo <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> a <span style="color: #339933;">=</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> addFive<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">a</span> <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;b &quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
Invoked with<span style="color: #339933;">:</span><br />
Foo f <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Bar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
f.<span style="color: #006633;">addFive</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">a</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
What is the result<span style="color: #339933;">?</span><br />
A. <span style="color: #006633;">b</span> <span style="color: #cc66cc;">3</span><br />
B. <span style="color: #006633;">b</span> <span style="color: #cc66cc;">8</span><br />
C. <span style="color: #006633;">b</span> <span style="color: #cc66cc;">13</span><br />
D. <span style="color: #006633;">f</span> <span style="color: #cc66cc;">3</span><br />
E. <span style="color: #006633;">f</span> <span style="color: #cc66cc;">8</span><br />
F. <span style="color: #006633;">f13</span><br />
G. <span style="color: #006633;">Compilation</span> fails.<br />
<span style="color: #006633;">H</span>. <span style="color: #006633;">An</span> exception is thrown at runtime.<br />
<span style="color: #006633;">Answer</span><span style="color: #339933;">:</span> A</div></td></tr></tbody></table></div>
<p>对于属性的覆盖，有如下结论：<br />
1.	由于private变量受访问权限的限制，它不能被覆盖。<br />
2.	属性的值取父类还是子类并不取决于我们创建对象的类型，而是取决于我们定义的变量的类型。<br />
3.	friendly、protected和public修饰符并不影响属性的覆盖。<br />
4.	静态变量和静态常量属于类，不属于对象，因此它们不能被覆盖。<br />
5.	常量可以被覆盖。 </p>
<p>对于第2条，也就是说Foo f = new Bar();<br />
取决于Foo类型，而不是Bar类型</p>
<p>因此，本题中由于是Foo f = new Bar();编译时看父类，执行看子类，将会执行子类addFive()方法，而在方法体中属性a带有this，也就是说它自身的属性，然后输出b，然后再执行f.a，由于f是Foo类的对象，因此它将调用的是Foo类的属性a，正是上面的第2条</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="希尔排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D93&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D336">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021996.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">希尔排序</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="ClassLoader详解" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D340&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D336">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021807.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">ClassLoader详解</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="快速排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D98&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D336">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10022017.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">快速排序</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="直接插入排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D158&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D336">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021992.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">直接插入排序</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.sky45.tk/?feed=rss2&#038;p=336</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>广州从兴电子开发2012校园招聘笔试题</title>
		<link>http://www.sky45.tk/?p=331</link>
		<comments>http://www.sky45.tk/?p=331#comments</comments>
		<pubDate>Sun, 16 Oct 2011 02:14:03 +0000</pubDate>
		<dc:creator>jame</dc:creator>
				<category><![CDATA[Java小知识]]></category>
		<category><![CDATA[对象引用]]></category>
		<category><![CDATA[数组]]></category>
		<category><![CDATA[笔试]]></category>

		<guid isPermaLink="false">http://jlife.tk/?p=331</guid>
		<description><![CDATA[昨天去了文汇面试，发现是五个人一起的，还是第一次被群面。主要就是让我们提出一个SSO(单点登录系统)的解决方案，要求保证安全性，实用性等。题目不难，关键是看解决问题时的过程，及各自的看法，因为面我们的两位美女都是HR(不懂技术的)，结束时还让我们自己投票。意外的是，晚上十点多的时候电话打给我说今天下午去复试，真是太兴奋了，不管结果怎样，我都要去努力去拼一拼，加油~~~ 说了那么多，还是回到本文的重点吧，其实该题是10.13考的，今天才有时间写点东西，所以就放上来了，题目如下： 1234567891011121314public class Confusing &#123; &#160; &#160; private Confusing&#40;Object o&#41;&#123; &#160; &#160; &#160; &#160; System.out.println&#40;&#34;Object&#34;&#41;; &#160; &#160; &#125; &#160; &#160; private Confusing&#40;double&#91;&#93; dArray&#41;&#123; &#160; &#160; &#160; &#160; System.out.println&#40;&#34;double array&#34;&#41;; &#160; &#160; &#125; &#160; &#160; public static void main&#40;String&#91;&#93; args&#41; &#160; &#160; &#123; &#160; &#160; &#160; &#160; new Confusing&#40;null&#41;; &#160; &#160; &#125; &#125; A.Object &#160; [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D57&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D331">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">对象引用例子</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D146&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D331">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">博克笔试中的一道递归题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D327&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D331">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">某安全公司2012校招笔试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D338&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D331">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Java参数传递的两种方式</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>     昨天去了文汇面试，发现是五个人一起的，还是第一次被群面。主要就是让我们提出一个SSO(单点登录系统)的解决方案，要求保证安全性，实用性等。题目不难，关键是看解决问题时的过程，及各自的看法，因为面我们的两位美女都是HR(不懂技术的)，结束时还让我们自己投票。意外的是，晚上十点多的时候电话打给我说今天下午去复试，真是太兴奋了，不管结果怎样，我都要去努力去拼一拼，加油~~~<br />
<span id="more-331"></span><br />
      说了那么多，还是回到本文的重点吧，其实该题是10.13考的，今天才有时间写点东西，所以就放上来了，题目如下：</p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Confusing<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> Confusing<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aobject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Object</span></a> o<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Object&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> Confusing<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">double</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> dArray<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;double array&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">new</span> Confusing<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
A.<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aobject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Object</span></a> &nbsp; &nbsp;B.<span style="color: #000066; font-weight: bold;">double</span> array &nbsp; &nbsp;C.<span style="color: #000066; font-weight: bold;">null</span> &nbsp; &nbsp;D.抛出空指针异常</div></td></tr></tbody></table></div>
<p>这道题，笔试时居然做错了，主要还是不了解数组的本质。<font color="red">数组的本质就是对象</font>，也就是可以这样赋值:double[] a = null;因此，在这道题中更匹配的数组的类型，程序将输出double array;若把null换成2，不再匹配数组类型，将输出Object。<br />
     另外，有个小疑问，既然它是最佳匹配的，而数组类型是可以赋值为null，所以才会去匹配它的，那String类型也是可以赋值为null，那在原代码的基础上再加上如下代码会得到什么样的结果呢？</p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">private</span> Confusing<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> str<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;string&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>分析：由于加了个String对象后，它将有两个都能同时匹配，因此编译器不知道该匹配谁，于是就成了编译错误：<br />
Confusing.java:15: 对 Confusing 的引用不明确，Confusing 中的 方法 Confusing(double[]) 和 Confusing 中的 方法 Confusing(java.lang.String) 都匹配new Confusing(null);</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D57&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D331">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">对象引用例子</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D146&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D331">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">博克笔试中的一道递归题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D327&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D331">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">某安全公司2012校招笔试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D338&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D331">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Java参数传递的两种方式</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.sky45.tk/?feed=rss2&#038;p=331</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>约瑟夫环</title>
		<link>http://www.sky45.tk/?p=329</link>
		<comments>http://www.sky45.tk/?p=329#comments</comments>
		<pubDate>Sat, 15 Oct 2011 09:02:47 +0000</pubDate>
		<dc:creator>jame</dc:creator>
				<category><![CDATA[Java小知识]]></category>
		<category><![CDATA[数据结构]]></category>
		<category><![CDATA[算法]]></category>

		<guid isPermaLink="false">http://jlife.tk/?p=329</guid>
		<description><![CDATA[问题描述：已知n个人（以编号1，2，3...n分别表示）围成一圈。从编号为k的人开始报数，数到m的那个人出列；他的下一个人又从1开始报数，数到m的那个人又出列；依此规律重复下去，直到圆桌周围的人全部出列，求最后一个出列人的编号。 12345int Josephus&#40;int n,int m,int k&#41;&#123; &#160; &#160;//参数分别为：人数，出圈步长，起使报数位置, &#160; &#160; for &#40;int i = 1; i &#60;= n; i++&#41; &#160; &#160; &#160; &#160; k = &#40;k + m - 1&#41; % i + 1; &#160; &#160; return k; //返回最后一人的位置 &#125;<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="某安全公司2012校招笔试题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D327&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D329">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">某安全公司2012校招笔试题</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="希尔排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D93&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D329">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021996.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">希尔排序</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="ClassLoader详解" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D340&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D329">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021807.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">ClassLoader详解</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="快速排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D98&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D329">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10022017.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">快速排序</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>问题描述：已知n个人（以编号1，2，3...n分别表示）围成一圈。从编号为k的人开始报数，数到m的那个人出列；他的下一个人又从1开始报数，数到m的那个人又出列；依此规律重复下去，直到圆桌周围的人全部出列，求最后一个出列人的编号。<br />
<span id="more-329"></span></p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000066; font-weight: bold;">int</span> Josephus<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> n,<span style="color: #000066; font-weight: bold;">int</span> m,<span style="color: #000066; font-weight: bold;">int</span> k<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">//参数分别为：人数，出圈步长，起使报数位置,</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;=</span> n<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; k <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>k <span style="color: #339933;">+</span> m <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> i <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> k<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//返回最后一人的位置</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="某安全公司2012校招笔试题" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D327&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D329">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">某安全公司2012校招笔试题</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="希尔排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D93&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D329">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021996.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">希尔排序</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="直接插入排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D158&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D329">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021992.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">直接插入排序</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="ClassLoader详解" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D340&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D329">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021807.jpg" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">ClassLoader详解</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.sky45.tk/?feed=rss2&#038;p=329</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>某安全公司2012校招笔试题</title>
		<link>http://www.sky45.tk/?p=327</link>
		<comments>http://www.sky45.tk/?p=327#comments</comments>
		<pubDate>Fri, 14 Oct 2011 15:08:02 +0000</pubDate>
		<dc:creator>jame</dc:creator>
				<category><![CDATA[数据结构]]></category>
		<category><![CDATA[笔试]]></category>
		<category><![CDATA[算法]]></category>

		<guid isPermaLink="false">http://jlife.tk/?p=327</guid>
		<description><![CDATA[m个人坐成一圈，编号1~m，从1开始报数，报到n的倍数的离开，求最后剩下的那个人编号。语言不限。<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D146&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D327">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">博克笔试中的一道递归题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D313&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D327">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">两个大数相乘</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D331&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D327">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">广州从兴电子开发2012校园招聘笔试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D307&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D327">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">将String转换成int的实现</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>m个人坐成一圈，编号1~m，从1开始报数，报到n的倍数的离开，求最后剩下的那个人编号。语言不限。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D146&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D327">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">博克笔试中的一道递归题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D313&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D327">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">两个大数相乘</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D331&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D327">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">广州从兴电子开发2012校园招聘笔试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D307&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D327">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">将String转换成int的实现</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.sky45.tk/?feed=rss2&#038;p=327</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>两个大数相乘</title>
		<link>http://www.sky45.tk/?p=313</link>
		<comments>http://www.sky45.tk/?p=313#comments</comments>
		<pubDate>Tue, 11 Oct 2011 11:07:13 +0000</pubDate>
		<dc:creator>jame</dc:creator>
				<category><![CDATA[String处理]]></category>
		<category><![CDATA[String]]></category>
		<category><![CDATA[笔试]]></category>

		<guid isPermaLink="false">http://jlife.tk/?p=313</guid>
		<description><![CDATA[其实，两个大数相乘，难免会出现溢出的现象，若两个很大的int值相乘，肯定会超过231-1。然而，要实现这个运算，你首先会想到的是BigDecimal和BigInteger类，通过这两个类的方法可以很方便的进行大数的运算，但是如何我们自己来实现呢？这里我将两数相乘的代码给出，其思想就是我们手工乘法的过程，代码如下： 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869import java.util.Arrays; import java.util.Scanner; &#160; public class BigMultiTest &#123; &#160; &#160; &#160; &#160; &#160; &#160; &#160; public static void main&#40;String&#91;&#93; args&#41; &#123; &#160; &#160; &#160; &#160; Scanner reader = new Scanner&#40;System.in&#41;; &#160; &#160; &#160; &#160; String numStr1 = reader.next&#40;&#41;; &#160; &#160; &#160; &#160; String numStr2 = reader.next&#40;&#41;; &#160; &#160; &#160; &#160; int&#91;&#93; intNum1 = [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D307&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D313">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">将String转换成int的实现</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D146&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D313">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">博克笔试中的一道递归题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D327&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D313">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">某安全公司2012校招笔试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D86&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D313">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">封装类型==和equals的区别</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>其实，两个大数相乘，难免会出现溢出的现象，若两个很大的int值相乘，肯定会超过2<sup>31</sup>-1。然而，要实现这个运算，你首先会想到的是BigDecimal和BigInteger类，通过这两个类的方法可以很方便的进行大数的运算，但是如何我们自己来实现呢？这里我将两数相乘的代码给出，其思想就是我们手工乘法的过程，代码如下：<br />
<span id="more-313"></span></p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Arrays</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Scanner</span><span style="color: #339933;">;</span> &nbsp; <br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BigMultiTest <span style="color: #009900;">&#123;</span> &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Scanner reader <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Scanner<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">in</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> numStr1 <span style="color: #339933;">=</span> reader.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> numStr2 <span style="color: #339933;">=</span> reader.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> intNum1 <span style="color: #339933;">=</span> changetoArray<span style="color: #009900;">&#40;</span>numStr1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> intNum2 <span style="color: #339933;">=</span> changetoArray<span style="color: #009900;">&#40;</span>numStr2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; multiply<span style="color: #009900;">&#40;</span>intNum1, intNum2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp; &nbsp; &nbsp;* 将字符串转换成int类型数组，注意从字符串的尾端开始存入数组中<br />
&nbsp; &nbsp; &nbsp;* @param numStr<br />
&nbsp; &nbsp; &nbsp;* @return <br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> changetoArray<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> numStr<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> length <span style="color: #339933;">=</span> numStr.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> intNum <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span>length<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> length<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; intNum<span style="color: #009900;">&#91;</span>length <span style="color: #339933;">-</span> i <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainteger+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Integer</span></a>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>numStr.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aarrays+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Arrays</span></a>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span>intNum<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> intNum<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> &nbsp; <br />
<br />
&nbsp; &nbsp; <span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp; &nbsp; &nbsp;* 两数相乘的核心算法<br />
&nbsp; &nbsp; &nbsp;* @param num1<br />
&nbsp; &nbsp; &nbsp;* @param num2<br />
&nbsp; &nbsp; &nbsp;* @return<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> multiply<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> num1,<span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> num2<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> length1 <span style="color: #339933;">=</span> num1.<span style="color: #006633;">length</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> length2 <span style="color: #339933;">=</span> num2.<span style="color: #006633;">length</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> result <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span>length1 <span style="color: #339933;">+</span> length2<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> length1<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span>length2<span style="color: #339933;">;</span>j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> temp <span style="color: #339933;">=</span> result<span style="color: #009900;">&#91;</span>i <span style="color: #339933;">+</span> j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> num1<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">*</span> num2<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result<span style="color: #009900;">&#91;</span>i <span style="color: #339933;">+</span> j<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> temp <span style="color: #339933;">%</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//将两数相乘与前面数的最高位相加的结果的个位存入数组</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result<span style="color: #009900;">&#91;</span>i <span style="color: #339933;">+</span> j <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+=</span> temp <span style="color: #339933;">/</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//下一位存入与之前结果的和的十位</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//如果大于10，就进1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#91;</span>i <span style="color: #339933;">+</span> j <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result<span style="color: #009900;">&#91;</span>i <span style="color: #339933;">+</span> j <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">%=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result<span style="color: #009900;">&#91;</span>i <span style="color: #339933;">+</span> j <span style="color: #339933;">+</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astringbuffer+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">StringBuffer</span></a> sb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astringbuffer+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">StringBuffer</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aarrays+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Arrays</span></a>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> result.<span style="color: #006633;">length</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sb.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> tempStr <span style="color: #339933;">=</span> sb.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//去掉字符串开始的0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> flag <span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>flag <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> flag <span style="color: #339933;">&lt;</span> result.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> flag<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>tempStr.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>flag<span style="color: #009900;">&#41;</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> resultStr <span style="color: #339933;">=</span> tempStr.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span>flag<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>resultStr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> result<span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> &nbsp;<br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D307&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D313">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">将String转换成int的实现</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D146&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D313">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">博克笔试中的一道递归题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D327&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D313">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">某安全公司2012校招笔试题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D86&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D313">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">封装类型==和equals的区别</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.sky45.tk/?feed=rss2&#038;p=313</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>将String转换成int的实现</title>
		<link>http://www.sky45.tk/?p=307</link>
		<comments>http://www.sky45.tk/?p=307#comments</comments>
		<pubDate>Tue, 11 Oct 2011 10:47:45 +0000</pubDate>
		<dc:creator>jame</dc:creator>
				<category><![CDATA[String处理]]></category>
		<category><![CDATA[String]]></category>
		<category><![CDATA[笔试]]></category>

		<guid isPermaLink="false">http://jlife.tk/?p=307</guid>
		<description><![CDATA[看到标题，也许你会问，用Integer.parseInt(String str)方法不就可以搞定了？没错，但这是Java已经写好的方法了，这里我要说的是我们自己来实现这个过程，大致代码如下： 123456789101112131415public class StringToInt &#123; &#160; &#160; public static int changetonum&#40;String str&#41; &#123; &#160; &#160; &#160; &#160; int result = 0; &#160; &#160; &#160; &#160; int len = str.length&#40;&#41;; &#160; &#160; &#160; &#160; for &#40;int i = 0; i &#60; len; i++&#41; &#123; &#160; &#160; &#160; &#160; &#160; &#160; result +=&#40;str.charAt&#40;i&#41;-'0'&#41;*Math.pow&#40;10, &#40;len-i-1&#41;&#41;; &#160; &#160; [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D313&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D307">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">两个大数相乘</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D86&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D307">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">封装类型==和equals的区别</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D146&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D307">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">博克笔试中的一道递归题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D327&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D307">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">某安全公司2012校招笔试题</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>看到标题，也许你会问，用Integer.parseInt(String str)方法不就可以搞定了？没错，但这是Java已经写好的方法了，这里我要说的是我们自己来实现这个过程，大致代码如下：<br />
<span id="more-307"></span></p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> StringToInt <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">int</span> changetonum<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> str<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> result <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> len <span style="color: #339933;">=</span> str.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> len<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result <span style="color: #339933;">+=</span><span style="color: #009900;">&#40;</span>str.<span style="color: #006633;">charAt</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Amath+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Math</span></a>.<span style="color: #006633;">pow</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span>, <span style="color: #009900;">&#40;</span>len<span style="color: #339933;">-</span>i<span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> result<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; changetonum<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;345&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>当然，看完代码的你会说，这代码有很大问题。没错，我这里只写了转换的核心思想，就是将字符串的每个字母转换成char，然后利用ASCII码来进行转换，而没有考虑原数超出int的范围、输入含有非数字的字母的异常捕获等问题，有兴趣的朋友可以自己完善一下。</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D313&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D307">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">两个大数相乘</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D86&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D307">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">封装类型==和equals的区别</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D146&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D307">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">博克笔试中的一道递归题</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D327&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D307">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">某安全公司2012校招笔试题</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.sky45.tk/?feed=rss2&#038;p=307</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>树的一些概念</title>
		<link>http://www.sky45.tk/?p=282</link>
		<comments>http://www.sky45.tk/?p=282#comments</comments>
		<pubDate>Sun, 02 Oct 2011 08:06:25 +0000</pubDate>
		<dc:creator>jame</dc:creator>
				<category><![CDATA[数据结构]]></category>
		<category><![CDATA[树]]></category>

		<guid isPermaLink="false">http://www.sky45.tk/?p=282</guid>
		<description><![CDATA[1.树结构 非终端节点:有子节点的节点 终端节点或叶子节点:没有子节点的节点 节点的度:一个节点的度是它拥有的子节点数;而一棵树的度是指树内各节点所拥有的度的最大值 层次:树中节点世代的关系，一代为一个层次，根的层为1 高度：树中某节点的高度表示此节点到叶子节点的最长路径长度 深度：某个节点的深度为根至此节点的路径长度 2.二叉树 二叉树：每个节点至多只有两颗子树（即二叉树中不存在度大于2的节点），并且二叉树中的子树有左右之分，其次序不能任意颠倒 性质： i． 在二叉树的第i层上至多有2i-1个节点(i&#62;=1) ii． 深度为k的二叉树至少有2k-1个节点，至多有2k-1个节点(k&#62;=1) iii． 对任何一颗二叉树T，如果其终端节点数为n0，度为2的节点数为n2，则n0=n2+1 一棵深度为k，且有2k-1个节点的二叉树称为满二叉树 对满二叉树进行编号，编号约定为从根节点开始，从上到下，从左到右。 深度为k的，有n个节点的二叉树，当且仅当其每个节点都与深度为k的满二叉树中编号从1到n的节点一一对应，称之为 完全二叉树 性质：具有n个节点的完全二叉树的深度为⌊log2n⌋+1 3.哈夫曼树 假设有n个权值{w1,w2,w3,...wn},试构造一棵有n个叶子节点的二叉树，每个叶子节点带权为wi，则其中带权路径长度WPL最小的二叉树为最优二叉树或者哈夫曼树 对于有n个叶子节点的哈夫曼树，总共有2n-1个节点。 4.二叉查找树 二叉查找树可以是空集合，假设不是，则树中每个节点均含有一个关键字(key value),且具有如下特性： i. 在左子树的所有关键字均小于根的关键字 ii. 在右子树的所有关键字均大于根的关键字 iii. 左子树和右子树是二叉查找树<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="二分查找" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D185&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D282">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">二分查找</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="希尔排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D93&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D282">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021996.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">希尔排序</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="直接插入排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D158&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D282">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021992.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">直接插入排序</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="快速排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D98&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D282">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10022017.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">快速排序</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>1.树结构</p>
<ol>
<li>非终端节点:有子节点的节点</li>
<li>终端节点或叶子节点:没有子节点的节点</li>
<li>节点的度:一个节点的度是它拥有的子节点数;而一棵树的度是指树内各节点所拥有的度的最大值</li>
<li>层次:树中节点世代的关系，一代为一个层次，根的层为1</li>
<li>高度：树中某节点的高度表示此节点到叶子节点的最长路径长度</li>
<li>深度：某个节点的深度为根至此节点的路径长度</li>
</ol>
<p><span id="more-282"></span><br />
2.二叉树<br />
二叉树：每个节点至多只有两颗子树（即二叉树中不存在度大于2的节点），并且二叉树中的子树有左右之分，其次序不能任意颠倒<br />
性质：<br />
<strong><br />
i．	在二叉树的第i层上至多有2<sup>i-1</sup>个节点(i&gt;=1)<br />
ii．	深度为k的二叉树至少有2<sup>k-1</sup>个节点，至多有2<sup>k</sup>-1个节点(k&gt;=1)<br />
iii．	对任何一颗二叉树T，如果其终端节点数为n<sub>0</sub>，度为2的节点数为n<sub>2</sub>，则n<sub>0</sub>=n<sub>2</sub>+1<br />
</strong><br />
一棵深度为k，且有2<sup>k</sup>-1个节点的二叉树称为满二叉树<br />
对满二叉树进行编号，编号约定为从根节点开始，从上到下，从左到右。 深度为k的，有n个节点的二叉树，当且仅当其每个节点都与深度为k的满二叉树中编号从1到n的节点一一对应，称之为 完全二叉树</p>
<p>性质：具有n个节点的完全二叉树的深度为⌊log<sub>2</sub>n⌋+1</p>
<p>3.哈夫曼树<br />
假设有n个权值{w<sub>1</sub>,w<sub>2</sub>,w<sub>3</sub>,...w<sub>n</sub>},试构造一棵有n个叶子节点的二叉树，每个叶子节点带权为w<sub>i</sub>，则其中带权路径长度WPL最小的二叉树为最优二叉树或者哈夫曼树</p>
<p>对于有n个叶子节点的哈夫曼树，总共有2n-1个节点。</p>
<p>4.二叉查找树<br />
二叉查找树可以是空集合，假设不是，则树中每个节点均含有一个关键字(key value),且具有如下特性：<br />
i.	在左子树的所有关键字均小于根的关键字<br />
ii.	在右子树的所有关键字均大于根的关键字<br />
iii.	左子树和右子树是二叉查找树</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="3" border="0"  style="clear: both;">
    
    <tr>
        <td colspan="4"><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
        <tr>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important;">
                    <a target="_blank" title="二分查找" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D185&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D282">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/images/blogWidget/wordpress_default.gif" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">二分查找</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="希尔排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D93&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D282">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021996.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">希尔排序</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="快速排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D98&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D282">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10022017.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">快速排序</font>
                    </a>
                </td>
                <td width="102" valign="top" style="padding: 5px !important; margin: 0 !important; border-left: 1px solid #DDDDDD !important;">
                    <a target="_blank" title="直接插入排序" style="text-decoration: none !important; cursor: pointer !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D158&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D282">
                        <img style="margin: 0 !important; padding: 2px !important; border: 1px solid #DDDDDD !important; width: 96px !important; height: 96px !important;" src="http://static.wumii.com/site_images/2011/10/30/10021992.png" width="96px" height="96px" /><br />
                        <font size="-1" color="#333333" style="display: block !important; line-height: 15px !important; width: 102px !important; font: 12px/15px arial !important; height: 60px !important; margin: 3px 0 0 0 !important; padding: 0 !important; overflow: hidden !important;">直接插入排序</font>
                    </a>
                </td>
        </tr>
    
    <tr>
        <td colspan="4" align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.sky45.tk/?feed=rss2&#038;p=282</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>双向链表结构</title>
		<link>http://www.sky45.tk/?p=278</link>
		<comments>http://www.sky45.tk/?p=278#comments</comments>
		<pubDate>Sun, 02 Oct 2011 07:47:12 +0000</pubDate>
		<dc:creator>jame</dc:creator>
				<category><![CDATA[数据结构]]></category>
		<category><![CDATA[链表]]></category>

		<guid isPermaLink="false">http://www.sky45.tk/?p=278</guid>
		<description><![CDATA[在双向链表的节点中有两个指针域，其一指向直接后继，另一指向直接前继。另外，双向链表也可以是循环的，最后节点的后继指针指向头节点，首先，双向链表的构造代码如下： 12345678class Node&#123; &#160; &#160; int data; &#160; &#160; Node llink; &#160; &#160; Node rlink; &#125; head = new Node&#40;&#41;; head.rlink = head; head.llink = head; 1.在头节点处插入节点,先把新增节点的左右指针赋值,然后在把该新增节点赋给旁边的节点 1234567current = head.rlink; Node node = new Node&#40;&#41;; node.data = i; node.rlink = current; node.llink = head; head.rlink = node; current.llink = node; 2.在链表尾部插入节点,由于是双向循环链表,因此找到尾节点就相当容易: 1234567current = head.llink; Node [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D276&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D278">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">循环链表结构</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D272&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D278">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">单链表结构</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D81&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D278">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">单向链表的实现</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D340&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D278">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">ClassLoader详解</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>在双向链表的节点中有两个指针域，其一指向直接后继，另一指向直接前继。另外，双向链表也可以是循环的，最后节点的后继指针指向头节点，首先，双向链表的构造代码如下：<br />
<span id="more-278"></span></p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">class</span> Node<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> data<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Node llink<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Node rlink<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
head <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Node<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
head.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> head<span style="color: #339933;">;</span><br />
head.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> head<span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>1.在头节点处插入节点,先把新增节点的左右指针赋值,然后在把该新增节点赋给旁边的节点</p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">current <span style="color: #339933;">=</span> head.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
Node node <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Node<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
node.<span style="color: #006633;">data</span> <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span><br />
node.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> current<span style="color: #339933;">;</span><br />
node.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> head<span style="color: #339933;">;</span><br />
head.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> node<span style="color: #339933;">;</span><br />
current.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> node<span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>2.在链表尾部插入节点,由于是双向循环链表,因此找到尾节点就相当容易:</p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">current <span style="color: #339933;">=</span> head.<span style="color: #006633;">llink</span><span style="color: #339933;">;</span><br />
Node node <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Node<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
node.<span style="color: #006633;">data</span> <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span><br />
node.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> current<span style="color: #339933;">;</span><br />
node.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> head<span style="color: #339933;">;</span><br />
current.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> node<span style="color: #339933;">;</span><br />
head.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> node<span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>3.在任意位置插入节点:</p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">current <span style="color: #339933;">=</span> head.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>current<span style="color: #339933;">!=</span>head <span style="color: #339933;">&amp;&amp;</span> current.<span style="color: #006633;">data</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; pre <span style="color: #339933;">=</span> current<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; current <span style="color: #339933;">=</span> current.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
Node node <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Node<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
node.<span style="color: #006633;">data</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">11</span><span style="color: #339933;">;</span><br />
node.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> current<span style="color: #339933;">;</span><br />
node.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> pre<span style="color: #339933;">;</span><br />
pre.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> node<span style="color: #339933;">;</span><br />
current.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> node<span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>4.在头部删除节点:</p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">current <span style="color: #339933;">=</span> head.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
current.<span style="color: #006633;">rlink</span>.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> head<span style="color: #339933;">;</span><br />
head.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> current.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
current <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>5.在尾部删除节点:</p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">current <span style="color: #339933;">=</span> head.<span style="color: #006633;">llink</span><span style="color: #339933;">;</span><br />
current.<span style="color: #006633;">llink</span>.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> head<span style="color: #339933;">;</span><br />
head.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> current.<span style="color: #006633;">llink</span><span style="color: #339933;">;</span><br />
current <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>6.在任意位置删除节点:</p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">current <span style="color: #339933;">=</span> head.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>current<span style="color: #339933;">!=</span>head <span style="color: #339933;">&amp;&amp;</span> current.<span style="color: #006633;">data</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">11</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; pre <span style="color: #339933;">=</span> current<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; current <span style="color: #339933;">=</span> current.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
current.<span style="color: #006633;">rlink</span>.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> pre<span style="color: #339933;">;</span><br />
pre.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> current.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
current <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>完整代码如下：</p>
<div class="codecolorer-container java mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> DoubleLinkedList <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">class</span> Node<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> data<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Node llink<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Node rlink<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">static</span> Node head<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">static</span> Node current<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">static</span> Node pre<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> DoubleLinkedList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; head <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Node<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; head.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> head<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; head.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> head<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//添加节点到头部</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> addFront<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> head.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Node node <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Node<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; node.<span style="color: #006633;">data</span> <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; node.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> current<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; node.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> head<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; head.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> node<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> node<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//添加节点到尾部</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> addRear<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> head.<span style="color: #006633;">llink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Node node <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Node<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; node.<span style="color: #006633;">data</span> <span style="color: #339933;">=</span> i<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; node.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> current<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; node.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> head<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> node<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; head.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> node<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//添加节点到任一位置</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> add<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> head.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>current<span style="color: #339933;">!=</span>head <span style="color: #339933;">&amp;&amp;</span> current.<span style="color: #006633;">data</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pre <span style="color: #339933;">=</span> current<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> current.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Node node <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Node<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; node.<span style="color: #006633;">data</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">11</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; node.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> current<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; node.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> pre<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; pre.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> node<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> node<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//在头部删除节点</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> removeFront<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> head.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current.<span style="color: #006633;">rlink</span>.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> head<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; head.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> current.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//在尾部删除节点</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> removeRear<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> head.<span style="color: #006633;">llink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current.<span style="color: #006633;">llink</span>.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> head<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; head.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> current.<span style="color: #006633;">llink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//在任意位置删除节点</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> remove<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> head.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>current<span style="color: #339933;">!=</span>head <span style="color: #339933;">&amp;&amp;</span> current.<span style="color: #006633;">data</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">11</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pre <span style="color: #339933;">=</span> current<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> current.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current.<span style="color: #006633;">rlink</span>.<span style="color: #006633;">llink</span> <span style="color: #339933;">=</span> pre<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; pre.<span style="color: #006633;">rlink</span> <span style="color: #339933;">=</span> current.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; DoubleLinkedList dll <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DoubleLinkedList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dll.<span style="color: #006633;">addFront</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dll.<span style="color: #006633;">addFront</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dll.<span style="color: #006633;">addFront</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dll.<span style="color: #006633;">addFront</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dll.<span style="color: #006633;">addFront</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dll.<span style="color: #006633;">addFront</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dll.<span style="color: #006633;">addFront</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dll.<span style="color: #006633;">addFront</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">8</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dll.<span style="color: #006633;">addFront</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> head.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>current<span style="color: #339933;">!=</span>head<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>current.<span style="color: #006633;">data</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> current.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>=======================&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; dll.<span style="color: #006633;">addRear</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> head.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>current<span style="color: #339933;">!=</span>head<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>current.<span style="color: #006633;">data</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> current.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>=======================&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dll.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> head.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>current<span style="color: #339933;">!=</span>head<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>current.<span style="color: #006633;">data</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> current.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>=======================&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dll.<span style="color: #006633;">removeFront</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> head.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>current<span style="color: #339933;">!=</span>head<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>current.<span style="color: #006633;">data</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> current.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>=======================&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dll.<span style="color: #006633;">removeRear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> head.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>current<span style="color: #339933;">!=</span>head<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>current.<span style="color: #006633;">data</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> current.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>=======================&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; dll.<span style="color: #006633;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> head.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>current<span style="color: #339933;">!=</span>head<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>current.<span style="color: #006633;">data</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current <span style="color: #339933;">=</span> current.<span style="color: #006633;">rlink</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p style="margin:0;padding:0;height:1px;overflow:hidden;">
    <script type="text/javascript"><!--
        var wumiiSitePrefix = "http://www.sky45.tk";
        var wumiiEnableCustomPos = false;
        var wumiiParams = "&#038;num=4&#038;mode=3&#038;displayInFeed=1&#038;version=1.0.5.5&#038;pf=WordPress3.2.1";
    //--></script><script type="text/javascript" src="http://widget.wumii.com/ext/relatedItemsWidget.htm"></script><a href="http://www.wumii.com/widget/relatedItems.htm" style="border:0;"><img src="http://static.wumii.com/images/pixel.png" alt="无觅相关文章插件，快速提升流量" style="border:0;padding:0;margin:0;" /></a></p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D276&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D278">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">循环链表结构</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D272&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D278">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">单链表结构</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D81&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D278">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">单向链表的实现</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect?url=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D340&from=http%3A%2F%2Fwww.sky45.tk%2F%3Fp%3D278">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">ClassLoader详解</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://www.sky45.tk/?feed=rss2&#038;p=278</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

