<?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>开心e点 &#187; java</title>
	<atom:link href="http://www.ebnd.cn/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ebnd.cn</link>
	<description>好好学习 天天向上</description>
	<lastBuildDate>Tue, 21 Jun 2011 15:00:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Eclipse 在 jdk1.6.0_14 下加断点调试经常停不下来</title>
		<link>http://www.ebnd.cn/2010/03/23/breakpoint-nonstop-in-eclipse-under-jdk1-6-0_14/</link>
		<comments>http://www.ebnd.cn/2010/03/23/breakpoint-nonstop-in-eclipse-under-jdk1-6-0_14/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 04:41:50 +0000</pubDate>
		<dc:creator>dandan</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[troubleshoot]]></category>

		<guid isPermaLink="false">http://www.ebnd.cn/?p=415</guid>
		<description><![CDATA[前阵碰到这个问题，一开始还以为是 Eclipse 的bug，导致调试无法进行，不知问题出在哪里。 在一段时间之后，终于忍受不了，google 了一把，找到了原因，是 jdk1.6.0_14 的bug导致的。 还比较复杂，大致Eclipse 在调试的过程中，假定已经创建好的线程ID是不变的，断点也绑定于某个线程，但是在 jdk1.6.0_14 中，这个ID值会被不可预知的改变，从而导致断点失效。 当时还没有修复，只好退回了 jdk1.6.0_13。 现在 jdk1.6.0_16 发布了，从release notes 来看，是专门解决这个问题的。记录之。 问题的相关链接： https://bugs.eclipse.org/bugs/show_bug.cgi?id=279137 http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6862295 http://java.sun.com/javase/6/webnotes/6u16.html http://hg.openjdk.java.net/jdk7/hotspot-rt/hotspot/rev/2b4230d1e589 注：去年在 javaeye 写的一篇文章，搬到这里来。 相关文章三月 15, 2010 -- Eclipse 远程调试 “Failed to connect to remote vm” error (1)三月 6, 2011 -- Windows / Linux 下使用符号链接完全指南 (1)二月 22, 2011 -- 如何修改浏览器Cookie (1)一月 27, 2011 [...]]]></description>
			<content:encoded><![CDATA[<div>前阵碰到这个问题，一开始还以为是 Eclipse 的bug，导致调试无法进行，不知问题出在哪里。 </p>
<p>在一段时间之后，终于忍受不了，google 了一把，找到了原因，是 jdk1.6.0_14 的bug导致的。 <br />
还比较复杂，大致Eclipse 在调试的过程中，假定已经创建好的线程ID是不变的，断点也绑定于某个线程，但是在 jdk1.6.0_14 中，这个ID值会被不可预知的改变，从而导致断点失效。 </p>
<p>当时还没有修复，只好退回了 jdk1.6.0_13。 </p>
<p>现在 jdk1.6.0_16 发布了，从release notes 来看，是专门解决这个问题的。记录之。 </p>
<p>
问题的相关链接： </p>
<p><a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=279137" target="_blank">https://bugs.eclipse.org/bugs/show_bug.cgi?id=279137</a> <br />
<a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6862295" target="_blank">http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6862295</a> <br />
<a href="http://java.sun.com/javase/6/webnotes/6u16.html" target="_blank">http://java.sun.com/javase/6/webnotes/6u16.html</a> <br />
<a href="http://hg.openjdk.java.net/jdk7/hotspot-rt/hotspot/rev/2b4230d1e589" target="_blank">http://hg.openjdk.java.net/jdk7/hotspot-rt/hotspot/rev/2b4230d1e589</a></div>
<p><br/></p>
<div><span style="color: #0000ff;">注：去年在 javaeye 写的<a href="http://moonese.javaeye.com/admin/blogs/450234">一篇文章</a>，搬到这里来。</span></div>
<p><br/></p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>三月 15, 2010 -- <a href="http://www.ebnd.cn/2010/03/15/eclipse-remote-debug-error/" title="Eclipse 远程调试 “Failed to connect to remote vm” error">Eclipse 远程调试 “Failed to connect to remote vm” error</a> (1)</li><li>三月 6, 2011 -- <a href="http://www.ebnd.cn/2011/03/06/guide-to-symbolic-link/" title="Windows / Linux 下使用符号链接完全指南">Windows / Linux 下使用符号链接完全指南</a> (1)</li><li>二月 22, 2011 -- <a href="http://www.ebnd.cn/2011/02/22/edit-browser-cookies/" title="如何修改浏览器Cookie">如何修改浏览器Cookie</a> (1)</li><li>一月 27, 2011 -- <a href="http://www.ebnd.cn/2011/01/27/software-collection-recommendation/" title="常用软件">常用软件</a> (0)</li><li>一月 11, 2011 -- <a href="http://www.ebnd.cn/2011/01/11/which-program-is-using-a-port/" title="查看占用端口的是什么程序">查看占用端口的是什么程序</a> (1)</li><li>十二月 15, 2010 -- <a href="http://www.ebnd.cn/2010/12/15/reload-pac-proxy-in-chrome/" title="Chrome 下重载 pac 代理设置">Chrome 下重载 pac 代理设置</a> (0)</li><li>十二月 7, 2010 -- <a href="http://www.ebnd.cn/2010/12/07/subversion-over-http-proxy/" title="通过 http 代理使用 subversion ">通过 http 代理使用 subversion </a> (0)</li><li>十一月 28, 2010 -- <a href="http://www.ebnd.cn/2010/11/28/embedding-groovy-script-in-windows-bat/" title="Windows .bat 文件中执行 Groovy 脚本">Windows .bat 文件中执行 Groovy 脚本</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ebnd.cn/2010/03/23/breakpoint-nonstop-in-eclipse-under-jdk1-6-0_14/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse 远程调试 “Failed to connect to remote vm” error</title>
		<link>http://www.ebnd.cn/2010/03/15/eclipse-remote-debug-error/</link>
		<comments>http://www.ebnd.cn/2010/03/15/eclipse-remote-debug-error/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 05:27:58 +0000</pubDate>
		<dc:creator>dandan</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.ebnd.cn/?p=371</guid>
		<description><![CDATA[Eclipse 远程调试错误，发现是网络设置导致的，去掉代理以后就好了。]]></description>
			<content:encoded><![CDATA[<p>最近发现在 Eclipse 中进行远程调试别的主机上的应用的时候，总是连接不上调试端口，报 “Failed to connect to remote vm”, 如下图所示：</p>
<p><img src="http://img.f.hatena.ne.jp/images/fotolife/e/ebnd/20100315/20100315131441.png?1268630171" alt="Failed to connect to remote vm" /></p>
<p>因为以前都是可以的，所以百思不得其解，Google了半天，能找到的问题一般也都是因为对方没有开启远程调试端口，所以自然连不上，但是我这里显然不是这个情况。在困惑了好久以后，突然想到会不会是受到了 Eclipse 代理设置的影响？虽然觉得不太可能，因为我的理解是那个代理只是给 Eclipse 本身用的，并不是给通过 Eclipse 启动的应用程序用的。但是结果证明是这个原因：</p>
<p>代理设置之前：</p>
<p><img src="http://img.f.hatena.ne.jp/images/fotolife/e/ebnd/20100315/20100315131443.png?1268630560" alt="Network Connection is set to 'Manual'" /></p>
<p>去掉代理之后，远程调试就可以了。</p>
<p><img src="http://img.f.hatena.ne.jp/images/fotolife/e/ebnd/20100315/20100315131442.png?1268630543" alt="Network Connection is set to 'Direct'" /></p>
<p>也许有人会觉得无聊，好好的 Eclipse 为什么要设置个代理呢。<br />
没办法啊，两个原因，一个是公司的网络出去的话会有点困难的；另外一个就是有些Eclipse插件被墙掉了，比如Maven，所以不得已，只能设置代理来更新插件了。</p>
<p><br/></p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>三月 23, 2010 -- <a href="http://www.ebnd.cn/2010/03/23/breakpoint-nonstop-in-eclipse-under-jdk1-6-0_14/" title="Eclipse 在 jdk1.6.0_14 下加断点调试经常停不下来">Eclipse 在 jdk1.6.0_14 下加断点调试经常停不下来</a> (0)</li><li>十二月 3, 2009 -- <a href="http://www.ebnd.cn/2009/12/03/code-snippet-to-compare-two-versions/" title="代码：比较两个版本大小">代码：比较两个版本大小</a> (2)</li><li>九月 24, 2009 -- <a href="http://www.ebnd.cn/2009/09/24/no-unsigned-type-in-java/" title="Java 语言没有 unsigned 类型">Java 语言没有 unsigned 类型</a> (0)</li><li>九月 14, 2009 -- <a href="http://www.ebnd.cn/2009/09/14/free-rmi-port-in-java/" title="在 Java 程序中释放 RMI 端口">在 Java 程序中释放 RMI 端口</a> (0)</li><li>九月 10, 2009 -- <a href="http://www.ebnd.cn/2009/09/10/java-prime-number-check/" title="[转] Java Prime number check">[转] Java Prime number check</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ebnd.cn/2010/03/15/eclipse-remote-debug-error/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>代码：比较两个版本大小</title>
		<link>http://www.ebnd.cn/2009/12/03/code-snippet-to-compare-two-versions/</link>
		<comments>http://www.ebnd.cn/2009/12/03/code-snippet-to-compare-two-versions/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 08:38:28 +0000</pubDate>
		<dc:creator>dandan</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.ebnd.cn/?p=342</guid>
		<description><![CDATA[最近项目需要写段代码来做版本的比较，需求大致是： 版本号一般是四位，如 1.0.0.10p7(也可能会少几位)，要求比较版本的 先后/大小 关系从而进行一些处理。 刚开始觉得是一个非常常用的功能，应该在很多地方都有现成实现的。但是找了一些开源的项目以后，都没有找到合适的。 像 Maven 里面是也有关于版本判断的代码，但是过于复杂，有好多个类。而我是想最好能有一个函数，把两个版本传进去，告诉我比较的结果就好了。 找不到，于是自己写了个，能满足我的要求了。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 [...]]]></description>
			<content:encoded><![CDATA[<p>最近项目需要写段代码来做版本的比较，需求大致是：<br />
版本号一般是四位，如 1.0.0.10p7(也可能会少几位)，要求比较版本的 先后/大小 关系从而进行一些处理。</p>
<p>刚开始觉得是一个非常常用的功能，应该在很多地方都有现成实现的。但是找了一些开源的项目以后，都没有找到合适的。</p>
<p>像 Maven 里面是也有关于版本判断的代码，但是过于复杂，有好多个类。而我是想最好能有一个函数，把两个版本传进去，告诉我比较的结果就好了。</p>
<p>找不到，于是自己写了个，能满足我的要求了。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Pattern PATTERN_DIGI_VERSION  <span style="color: #339933;">=</span> Pattern.<span style="color: #006633;">compile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;([<span style="color: #000099; font-weight: bold;">\\</span>d<span style="color: #000099; font-weight: bold;">\\</span>.]+)([abp]<span style="color: #000099; font-weight: bold;">\\</span>d+)?&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        ...
&nbsp;
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Compare two version strings, such as 1.0.0.10p7 and 1.0.0.20
	 * 
	 * @param lv, the left version string to be compared
	 * @param rv, the right version string to be compared
	 * @return, 1 if lv&gt;rv; 0 if lv==rv; -1 if lv&lt;rv
	 */</span>
	<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> compareVersion<span style="color: #009900;">&#40;</span> <span style="color: #003399;">String</span> lv, <span style="color: #003399;">String</span> rv <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> lvs <span style="color: #339933;">=</span> lv.<span style="color: #006633;">split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> rvs <span style="color: #339933;">=</span> rv.<span style="color: #006633;">split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">int</span> lmin <span style="color: #339933;">=</span> <span style="color: #003399;">Math</span>.<span style="color: #006633;">min</span><span style="color: #009900;">&#40;</span>lvs.<span style="color: #006633;">length</span>, rvs.<span style="color: #006633;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&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>lmin<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			Matcher lmatch <span style="color: #339933;">=</span> PATTERN_DIGI_VERSION.<span style="color: #006633;">matcher</span><span style="color: #009900;">&#40;</span>lvs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			Matcher rmatch <span style="color: #339933;">=</span> PATTERN_DIGI_VERSION.<span style="color: #006633;">matcher</span><span style="color: #009900;">&#40;</span>rvs<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> lmatch.<span style="color: #006633;">matches</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">int</span> lv1 <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>lmatch.<span style="color: #006633;">group</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #003399;">String</span> strlv2 <span style="color: #339933;">=</span> lmatch.<span style="color: #006633;">group</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> rmatch.<span style="color: #006633;">matches</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000066; font-weight: bold;">int</span> rv1 <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>rmatch.<span style="color: #006633;">group</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #003399;">String</span> strrv2 <span style="color: #339933;">=</span> rmatch.<span style="color: #006633;">group</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
					<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> lv1 <span style="color: #339933;">&gt;</span> rv1 <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> lv1 <span style="color: #339933;">&lt;</span> rv1 <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #666666; font-style: italic;">// compare to minor version, such a, b, p1, p3, etc. </span>
						<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> strlv2 <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">||</span> strlv2.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
							<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> strrv2 <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> strrv2.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span><span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
							<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> strrv2 <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">||</span> strrv2.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
							<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
								<span style="color: #003399;">String</span> wlv <span style="color: #339933;">=</span> strlv2.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
								<span style="color: #000066; font-weight: bold;">int</span> lv2 <span style="color: #339933;">=</span> strlv2 <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">?</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">:</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>strlv2.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
								<span style="color: #003399;">String</span> wrv <span style="color: #339933;">=</span> strrv2.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
								<span style="color: #000066; font-weight: bold;">int</span> rv2 <span style="color: #339933;">=</span> strrv2 <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">?</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">:</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>strrv2.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
								<span style="color: #666666; font-style: italic;">// compare small version string first, such as 'a', 'b', 'p'</span>
								<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> wlv.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span>wrv<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
								<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> wlv.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span>wrv<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
								<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
									<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> lv2 <span style="color: #339933;">&gt;</span> rv2 <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
									<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> lv2 <span style="color: #339933;">&lt;</span> rv2 <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
								<span style="color: #009900;">&#125;</span>
							<span style="color: #009900;">&#125;</span>
						<span style="color: #009900;">&#125;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> lmin <span style="color: #339933;">&lt;</span> lvs.<span style="color: #006633;">length</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> lmin <span style="color: #339933;">==</span> lvs.<span style="color: #006633;">length</span> <span style="color: #339933;">&amp;&amp;</span> lmin <span style="color: #339933;">==</span> rvs.<span style="color: #006633;">length</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><br/></p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>三月 23, 2010 -- <a href="http://www.ebnd.cn/2010/03/23/breakpoint-nonstop-in-eclipse-under-jdk1-6-0_14/" title="Eclipse 在 jdk1.6.0_14 下加断点调试经常停不下来">Eclipse 在 jdk1.6.0_14 下加断点调试经常停不下来</a> (0)</li><li>三月 15, 2010 -- <a href="http://www.ebnd.cn/2010/03/15/eclipse-remote-debug-error/" title="Eclipse 远程调试 “Failed to connect to remote vm” error">Eclipse 远程调试 “Failed to connect to remote vm” error</a> (1)</li><li>九月 24, 2009 -- <a href="http://www.ebnd.cn/2009/09/24/no-unsigned-type-in-java/" title="Java 语言没有 unsigned 类型">Java 语言没有 unsigned 类型</a> (0)</li><li>九月 14, 2009 -- <a href="http://www.ebnd.cn/2009/09/14/free-rmi-port-in-java/" title="在 Java 程序中释放 RMI 端口">在 Java 程序中释放 RMI 端口</a> (0)</li><li>九月 10, 2009 -- <a href="http://www.ebnd.cn/2009/09/10/java-prime-number-check/" title="[转] Java Prime number check">[转] Java Prime number check</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ebnd.cn/2009/12/03/code-snippet-to-compare-two-versions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Java 语言没有 unsigned 类型</title>
		<link>http://www.ebnd.cn/2009/09/24/no-unsigned-type-in-java/</link>
		<comments>http://www.ebnd.cn/2009/09/24/no-unsigned-type-in-java/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 03:32:45 +0000</pubDate>
		<dc:creator>dandan</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.ebnd.cn/?p=264</guid>
		<description><![CDATA[跟 C 语言不同，Java 中没有 unsigned 类型，这点可能让很多人都有过困扰。 那如果碰到确实需要用到 unsigned 类型的情况怎么办呢？ 通常的办法就是用更大一号的类型来处理，比如： 处理 unsigned byte，就用 int； 处理 unsigned int，就用 long； 处理 unsigned long，这个不好办，只能用 BigInteger 了。但是要注意的是，Java 中的 long 是 8 bytes，而 C 语言只有4 bytes，所以碰到这种情况的话，那就等同于上面 unsigned int 的情况了。 另外，Java 中比 C 语言增加了一种不带符号的移位操作： >>> ，固定的用 0 来填充左边高位的空缺，这在一定程度上减轻了没有 unsigned 类型带来的影响。 扩展阅读：这里有篇文章介绍了 Java 中怎么处理 unsigned 类型的。文中提到的一篇对 C /C++/Java 语言创始人的访谈中提到了 Java 中没有定义 unsigned [...]]]></description>
			<content:encoded><![CDATA[<p>跟 C 语言不同，Java 中没有 unsigned 类型，这点可能让很多人都有过困扰。</p>
<p>那如果碰到确实需要用到 unsigned 类型的情况怎么办呢？ 通常的办法就是用更大一号的类型来处理，比如：</p>
<ul>
<li><span style="background-color: #ffffff;">处理 unsigned byte，就用 int； </span></li>
<li><span style="background-color: #ffffff;">处理 unsigned int，就用 long；</span></li>
<li><span style="background-color: #ffffff;">处理 unsigned long，这个不好办，只能用 BigInteger 了。但是要注意的是，Java 中的 long 是 8 bytes，而 C 语言只有4 bytes，所以碰到这种情况的话，那就等同于上面 unsigned int 的情况了。</span></li>
</ul>
<p>另外，Java 中比 C 语言增加了一种不带符号的移位操作： <span style="color: #0000ff;">>>></span> ，固定的用 0 来填充左边高位的空缺，这在一定程度上减轻了没有 unsigned 类型带来的影响。</p>
<p><br class="spacer_" /></p>
<p>扩展阅读：这里<a title="Java and unsigned int, unsigned short, unsigned byte, unsigned long, etc. (Or rather, the lack thereof)" href="http://www.darksleep.com/player/JavaAndUnsignedTypes.html" target="_blank">有篇文章</a>介绍了 Java 中怎么处理 unsigned 类型的。文中提到的一篇<a title="The C Family of Languages: Interview with Dennis Ritchie, Bjarne Stroustrup, and James Gosling " href="http://www.gotw.ca/publications/c_family_interview.htm" target="_blank">对 C /C++/Java 语言创始人的访谈</a>中提到了 Java 中没有定义 unsigned 类型的原因，见最后 Gosling 的部分：</p>
<pre>Q: Programmers often talk about the advantages and disadvantages of programming
in a "simple language."  What does that phrase mean to you, and is [C/C++/Java] a
simple language in your view?

Ritchie: C (and the others for that matter) are simple in some ways, though they are
also subtle; other, somewhat similar languages like Pascal are arguably simpler. What
has become clear is that aspects of the environment like libraries that aren't part of
the core language are much bigger and more complicated. The 1999 C standard grew
hugely more in the library part than in the language; the C++ STL and other things
are big; AWT and other things associated with Java are too.

Stroustrup: I see three obvious notions of "simple:" to be easy to learn, to make it
easy to express ideas, and to have a one-to-one correspondence to some form of
math. In those terms, none of the three languages is simple. However, once mastered,
C and C++ make it easy to express quite complex and advanced ideas -- especially
when those ideas have to be expressed under real-world resource constraints.

Gosling: For me as a language designer, which I don't really count myself as these days,
what "simple" really ended up meaning was could I expect J. Random Developer to
hold the spec in his head. That definition says that, for instance, Java isn't -- and
in fact a lot of these languages end up with a lot of corner cases, things that nobody
really understands. Quiz any C developer about unsigned, and pretty soon you discover
that almost no C developers actually understand what goes on with unsigned,
what unsigned arithmetic is. Things like that made C complex.
The language part of Java is, I think, pretty simple. The libraries you have to look up.
</pre>
<p><br class="spacer_" /></p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>三月 23, 2010 -- <a href="http://www.ebnd.cn/2010/03/23/breakpoint-nonstop-in-eclipse-under-jdk1-6-0_14/" title="Eclipse 在 jdk1.6.0_14 下加断点调试经常停不下来">Eclipse 在 jdk1.6.0_14 下加断点调试经常停不下来</a> (0)</li><li>三月 15, 2010 -- <a href="http://www.ebnd.cn/2010/03/15/eclipse-remote-debug-error/" title="Eclipse 远程调试 “Failed to connect to remote vm” error">Eclipse 远程调试 “Failed to connect to remote vm” error</a> (1)</li><li>十二月 3, 2009 -- <a href="http://www.ebnd.cn/2009/12/03/code-snippet-to-compare-two-versions/" title="代码：比较两个版本大小">代码：比较两个版本大小</a> (2)</li><li>九月 14, 2009 -- <a href="http://www.ebnd.cn/2009/09/14/free-rmi-port-in-java/" title="在 Java 程序中释放 RMI 端口">在 Java 程序中释放 RMI 端口</a> (0)</li><li>九月 10, 2009 -- <a href="http://www.ebnd.cn/2009/09/10/java-prime-number-check/" title="[转] Java Prime number check">[转] Java Prime number check</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ebnd.cn/2009/09/24/no-unsigned-type-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在 Java 程序中释放 RMI 端口</title>
		<link>http://www.ebnd.cn/2009/09/14/free-rmi-port-in-java/</link>
		<comments>http://www.ebnd.cn/2009/09/14/free-rmi-port-in-java/#comments</comments>
		<pubDate>Sun, 13 Sep 2009 23:55:28 +0000</pubDate>
		<dc:creator>dandan</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[rmi]]></category>

		<guid isPermaLink="false">http://www.ebnd.cn/?p=168</guid>
		<description><![CDATA[通过 LocateRegistry.createRegistry(port) 创建了一个 rmiregistry 监听 port 所在端口， 如果想要在程序中把这个端口关闭，也就是关闭 RMI registry 服务，可以参考以下的代码。 注：似乎在2003年的时候，这个方法还行不通，到了 JDK6 的版本才解决这个问题的。 参考 Sun bug 4457683， bug 4508962， 以及 这个 mail archive。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [...]]]></description>
			<content:encoded><![CDATA[<p>通过 <span style="color: #0000ff;">LocateRegistry.createRegistry(port) </span>创建了一个 rmiregistry 监听 port 所在端口，</p>
<p>如果想要在程序中把这个端口关闭，也就是关闭 RMI registry 服务，可以参考以下的代码。</p>
<p>注：似乎在2003年的时候，<a title="http://osdir.com/ml/java.sun.rmi/2003-11/msg00005.html" href="http://osdir.com/ml/java.sun.rmi/2003-11/msg00005.html" target="_blank">这个方法还行不通</a>，到了 JDK6 的版本才解决这个问题的。</p>
<p>参考 Sun  <a title="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4457683" href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4457683" target="_blank">bug 4457683</a>， <a title="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508962" href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508962" target="_blank">bug 4508962</a>， 以及 <a title="http://archives.java.sun.com/cgi-bin/wa?A2=ind0507&#038;L=rmi-users&#038;P=4036" href="http://archives.java.sun.com/cgi-bin/wa?A2=ind0507&#038;L=rmi-users&#038;P=4036" target="_blank">这个 mail archive</a>。</p>
<p><br class="spacer_" /></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.rmi.NoSuchObjectException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.rmi.Remote</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.rmi.RemoteException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.rmi.registry.LocateRegistry</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RMITest <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testRMIPortRelease<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Testing port release&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Acquiring port... &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">Remote</span> reg <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			reg <span style="color: #339933;">=</span> <span style="color: #003399;">LocateRegistry</span>.<span style="color: #006633;">createRegistry</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1102</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">RemoteException</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			ex.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;releasing port... &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			java.<span style="color: #006633;">rmi</span>.<span style="color: #006633;">server</span>.<span style="color: #003399;">UnicastRemoteObject</span>.<span style="color: #006633;">unexportObject</span><span style="color: #009900;">&#40;</span>reg, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">NoSuchObjectException</span> ex1<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			ex1.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		reg <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&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><span style="color: #003399;">String</span><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>
		RMITest s <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> RMITest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		s.<span style="color: #006633;">testRMIPortRelease</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p><br class="spacer_" /></p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>三月 23, 2010 -- <a href="http://www.ebnd.cn/2010/03/23/breakpoint-nonstop-in-eclipse-under-jdk1-6-0_14/" title="Eclipse 在 jdk1.6.0_14 下加断点调试经常停不下来">Eclipse 在 jdk1.6.0_14 下加断点调试经常停不下来</a> (0)</li><li>三月 15, 2010 -- <a href="http://www.ebnd.cn/2010/03/15/eclipse-remote-debug-error/" title="Eclipse 远程调试 “Failed to connect to remote vm” error">Eclipse 远程调试 “Failed to connect to remote vm” error</a> (1)</li><li>十二月 3, 2009 -- <a href="http://www.ebnd.cn/2009/12/03/code-snippet-to-compare-two-versions/" title="代码：比较两个版本大小">代码：比较两个版本大小</a> (2)</li><li>九月 24, 2009 -- <a href="http://www.ebnd.cn/2009/09/24/no-unsigned-type-in-java/" title="Java 语言没有 unsigned 类型">Java 语言没有 unsigned 类型</a> (0)</li><li>九月 10, 2009 -- <a href="http://www.ebnd.cn/2009/09/10/java-prime-number-check/" title="[转] Java Prime number check">[转] Java Prime number check</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ebnd.cn/2009/09/14/free-rmi-port-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[转] Java Prime number check</title>
		<link>http://www.ebnd.cn/2009/09/10/java-prime-number-check/</link>
		<comments>http://www.ebnd.cn/2009/09/10/java-prime-number-check/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 04:56:46 +0000</pubDate>
		<dc:creator>dandan</dc:creator>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.ebnd.cn/?p=151</guid>
		<description><![CDATA[原文出处： http://ventrix.nsdc.gr/code_folds/2008/10/07/java-prime-number/ Information about the author: http://kospol.nsdc.gr/ ======================================================================== This is one approach to check if the given number is a prime number. It can take a very big number as an argument. It uses no threads and has no comments. Think it as version 0.01. 1 2 3 4 5 6 7 8 9 10 [...]]]></description>
			<content:encoded><![CDATA[<p>原文出处： <a href="http://ventrix.nsdc.gr/code_folds/2008/10/07/java-prime-number/" target="_blank">http://ventrix.nsdc.gr/code_folds/2008/10/07/java-prime-number/</a></p>
<p>Information about the author: <a href="http://kospol.nsdc.gr/" target="_blank">http://kospol.nsdc.gr/</a></p>
<p><br/></p>
<p>========================================================================</p>
<p>This is one approach to check if the given number is a prime number. It can take a very big number as an argument. It uses no threads and has no comments. Think it as version 0.01.</p>
<p><br/></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
 *      Prime.java
 *
 *      Copyright 2008 Ventrix &lt;ventrix@gmail.com&gt;
 *
 *      http://ventrix.nsdc.gr/code_folds/
 *
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */</span>  
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.math.BigInteger</span><span style="color: #339933;">;</span>  
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Prime <span style="color: #009900;">&#123;</span>  
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">long</span> start<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">long</span> end<span style="color: #339933;">;</span>  
&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><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> argv<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">boolean</span> isprimen<span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">//http://java.sun.com/j2se/1.4.2/docs/api/java/math/BigInteger.html#isProbablePrime(int)</span>
        <span style="color: #666666; font-style: italic;">//http://primes.utm.edu/lists/small/small.html</span>
        <span style="color: #666666; font-style: italic;">//for i in `seq 1 1000`; do java Prime $i &gt;&gt; primes; done</span>
        <span style="color: #666666; font-style: italic;">//cat primes | grep &quot;is a&quot;</span>
        start <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">BigInteger</span> bigNumber <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BigInteger</span><span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>bigNumber.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BigInteger</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;2147483647&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>bigNumber.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BigInteger</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;9223372036854775807&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #003399;">Long</span> longNumber <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Long</span><span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    bigNumber <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
                    isprimen <span style="color: #339933;">=</span> isNorPrime<span style="color: #009900;">&#40;</span>longNumber<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                    isprimen <span style="color: #339933;">=</span> isBigPrime<span style="color: #009900;">&#40;</span>bigNumber<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                bigNumber <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
                <span style="color: #003399;">Integer</span> intNumber <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Integer</span><span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                isprimen <span style="color: #339933;">=</span> isPrime<span style="color: #009900;">&#40;</span>intNumber<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>  
&nbsp;
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isprimen<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; is a prime!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; is NOT a prime!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            end <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Completed in +&quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>end <span style="color: #339933;">-</span> start<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;ms&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>  
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">boolean</span> isBigPrime<span style="color: #009900;">&#40;</span><span style="color: #003399;">BigInteger</span> number<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;You gave me a BIG number&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">BigInteger</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> remain<span style="color: #339933;">;</span>
        remain <span style="color: #339933;">=</span> number.<span style="color: #006633;">divideAndRemainder</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BigInteger</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Integer</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;2&quot;</span><span style="color: #009900;">&#41;</span>.<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: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>remain<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BigInteger</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        remain <span style="color: #339933;">=</span> number.<span style="color: #006633;">divideAndRemainder</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BigInteger</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Integer</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;3&quot;</span><span style="color: #009900;">&#41;</span>.<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: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>remain<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BigInteger</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">int</span> y <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> x <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span> <span style="color: #003399;">Math</span>.<span style="color: #006633;">sqrt</span><span style="color: #009900;">&#40;</span>number.<span style="color: #006633;">doubleValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <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;">5</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;=</span> x<span style="color: #339933;">;</span> i <span style="color: #339933;">+=</span> y, y <span style="color: #339933;">=</span> <span style="color: #cc66cc;">6</span> <span style="color: #339933;">-</span> y<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            remain <span style="color: #339933;">=</span> number.<span style="color: #006633;">divideAndRemainder</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BigInteger</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Integer</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<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: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>remain<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BigInteger</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>  
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">boolean</span> isNorPrime<span style="color: #009900;">&#40;</span><span style="color: #003399;">Long</span> number<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;You gave me a normal number&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>number <span style="color: #339933;">%</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>number <span style="color: #339933;">%</span> <span style="color: #cc66cc;">3</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">int</span> y <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> x <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span> <span style="color: #003399;">Math</span>.<span style="color: #006633;">sqrt</span><span style="color: #009900;">&#40;</span>number<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <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;">5</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;=</span> x<span style="color: #339933;">;</span> i <span style="color: #339933;">+=</span> y, y <span style="color: #339933;">=</span> <span style="color: #cc66cc;">6</span> <span style="color: #339933;">-</span> y<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>number <span style="color: #339933;">%</span> i <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>  
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">boolean</span> isPrime<span style="color: #009900;">&#40;</span><span style="color: #003399;">Integer</span> number<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;You gave me a small number&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>number <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>number <span style="color: #339933;">==</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>number <span style="color: #339933;">%</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>number <span style="color: #339933;">==</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>number <span style="color: #339933;">%</span> <span style="color: #cc66cc;">3</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">int</span> y <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> x <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span> <span style="color: #003399;">Math</span>.<span style="color: #006633;">sqrt</span><span style="color: #009900;">&#40;</span>number<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <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;">5</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;=</span> x<span style="color: #339933;">;</span> i <span style="color: #339933;">+=</span> y, y <span style="color: #339933;">=</span> <span style="color: #cc66cc;">6</span> <span style="color: #339933;">-</span> y<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>number <span style="color: #339933;">%</span> i <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #666666; font-style: italic;">//class&lt;/ventrix@gmail.com&gt;</span></pre></td></tr></table></div>

<p><br class="spacer_" /></p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li>三月 23, 2010 -- <a href="http://www.ebnd.cn/2010/03/23/breakpoint-nonstop-in-eclipse-under-jdk1-6-0_14/" title="Eclipse 在 jdk1.6.0_14 下加断点调试经常停不下来">Eclipse 在 jdk1.6.0_14 下加断点调试经常停不下来</a> (0)</li><li>三月 15, 2010 -- <a href="http://www.ebnd.cn/2010/03/15/eclipse-remote-debug-error/" title="Eclipse 远程调试 “Failed to connect to remote vm” error">Eclipse 远程调试 “Failed to connect to remote vm” error</a> (1)</li><li>十二月 3, 2009 -- <a href="http://www.ebnd.cn/2009/12/03/code-snippet-to-compare-two-versions/" title="代码：比较两个版本大小">代码：比较两个版本大小</a> (2)</li><li>九月 24, 2009 -- <a href="http://www.ebnd.cn/2009/09/24/no-unsigned-type-in-java/" title="Java 语言没有 unsigned 类型">Java 语言没有 unsigned 类型</a> (0)</li><li>九月 14, 2009 -- <a href="http://www.ebnd.cn/2009/09/14/free-rmi-port-in-java/" title="在 Java 程序中释放 RMI 端口">在 Java 程序中释放 RMI 端口</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ebnd.cn/2009/09/10/java-prime-number-check/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

