<?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>Information Retrieval Blog &#187; Java</title>
	<atom:link href="http://blog.zye.me/category/java/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.zye.me</link>
	<description>REAL TIME DATA PROCESSING, DISTRIBUTED COMPUTING, PATTERN DISCOVERY</description>
	<lastBuildDate>Tue, 31 Jan 2012 02:05:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Solr Error: A SPI class of type org.apache.lucene.index.codecs.Codec with name &#8216;Lucene40&#8242; does not exist</title>
		<link>http://blog.zye.me/2011/11/55863.html</link>
		<comments>http://blog.zye.me/2011/11/55863.html#comments</comments>
		<pubDate>Mon, 14 Nov 2011 07:30:35 +0000</pubDate>
		<dc:creator>yezheng</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[IR]]></category>
		<category><![CDATA[lucene]]></category>
		<category><![CDATA[Lucene40]]></category>
		<category><![CDATA[Solr]]></category>

		<guid isPermaLink="false">http://blog.zye.me/2011/11/55863.html</guid>
		<description><![CDATA[When you are testing Solr in Eclipse, you may encounter the problem that &#8220;A SPI class of type org.apache.lucene.index.codecs.Codec with name &#8216;Lucene40&#8242; does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath.The current classpath supports the following names: []&#8221; The fast answer to tackle this problem is to <a href='http://blog.zye.me/2011/11/55863.html'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>When you are testing Solr in Eclipse, you may encounter the problem that &#8220;A SPI class of type org.apache.lucene.index.codecs.Codec with name &#8216;Lucene40&#8242; does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath.The current classpath supports the following names: []&#8221;</p>
<p>The fast answer to tackle this problem is to add the lucene-core*.jar to the libaries of your project, and make sure that the file /META-INF/services/org.apache.lucene.index.codecs.Codec is included in lucene-core*.jar.&nbsp;</p>
<p>The problem is caused by the class of java.util.ServiceLoader used in&nbsp;NamedSPILoader of Solr. When ServiceLoader creates a new service provider, it will extract some information from&nbsp;/META-INF/services/org.apache.lucene.index.codecs.Codec. Therefore when you use build classes rather than the lucene-core*.jar file, the needed information can not be obtained. By now, I think you can handle this problem yourself.&nbsp;</p>
<p>For more information about How ServiceLoader work, please refer to:&nbsp;</p>
<p><a href="http://jcs.mobile-utopia.com/jcs/19273_ServiceLoader.java">http://jcs.mobile-utopia.com/jcs/19273_ServiceLoader.java</a>&nbsp;In English</p>
<p><a href="http://mxdxm.iteye.com/blog/1059300">http://mxdxm.iteye.com/blog/1059300</a>&nbsp;In Chinese</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zye.me/2011/11/55863.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>java Map的访问方法备忘，Comparator例子</title>
		<link>http://blog.zye.me/2011/09/3895.html</link>
		<comments>http://blog.zye.me/2011/09/3895.html#comments</comments>
		<pubDate>Mon, 12 Sep 2011 16:52:21 +0000</pubDate>
		<dc:creator>yezheng</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Comparator]]></category>
		<category><![CDATA[Map]]></category>

		<guid isPermaLink="false">http://www.5yiso.cn/articles/java-map%e7%9a%84%e8%ae%bf%e9%97%ae%e6%96%b9%e6%b3%95%e5%a4%87%e5%bf%98%ef%bc%8ccomparator%e4%be%8b%e5%ad%90.html</guid>
		<description><![CDATA[1.把Map中的Key或Value转化为数组 HashMap ssMap = new HashMap();  Counter counters[] = new Counter[ssMap.size()]; ssMap.values().toArray(counters); //转化，counters不需实例化 Arrays.sort(counters,new DfComparator());//排序 2. Comparator 实例 继承Comparator也可以实现排序，但相对Comparable接口更加灵活，用不同的Comparator实例可以实现不同的排序方法 class DfComparator implements Comparator { public int compare(Object o1, Object o2) { // TODO Auto-generated method stub Counter c1 = (Counter)o1; Counter c2 = (Counter)o2;   return c2.df &#8211; c1.df; } public boolean equals(Object obj) { return true; <a href='http://blog.zye.me/2011/09/3895.html'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><font face="Verdana">  </font><font face="Verdana">1.把Map中的Key或Value转化为数组</font></p>
<p><font face="Verdana">  </font><font face="Verdana">HashMap ssMap = new HashMap(); </font></p>
<p><font face="Verdana">  </font><font face="Verdana">Counter counters[] = new   Counter[ssMap.size()];<br />
ssMap.values().toArray(counters); //转化，counters不需实例化<br />
Arrays.sort(counters,new   DfComparator());//排序</font></p>
<p><font face="Verdana">  </font><font face="Verdana">2. Comparator 实例</font></p>
<p><font face="Verdana">  </font><font face="Verdana">继承Comparator也可以实现排序，但相对Comparable接口更加灵活，用不同的Comparator实例可以实现不同的排序方法</font></p>
<p><font face="Verdana">  </font><font face="Verdana">class DfComparator implements Comparator<br />
{<br />
public int   compare(Object o1, Object o2) {<br />
// TODO Auto-generated method   stub<br />
Counter c1 = (Counter)o1;<br />
Counter c2 =   (Counter)o2;</font></p>
<p><font face="Verdana">  </font><font face="Verdana">  return c2.df &#8211; c1.df;<br />
}<br />
public boolean   equals(Object obj)<br />
{<br />
return   true;<br />
}</p>
<p>}</font></p>
<p><font face="Verdana">  </font><font face="Verdana">3.Map访问语句备忘</font></p>
<p><font face="Verdana">  </font><font face="Verdana"> public static void print(Map map)<br />
{<br />
Set set =   map.entrySet();<br />
Iterator iter =   set.iterator();<br />
while(iter.hasNext())<br />
{<br />
Map.Entry   entry =   (Map.Entry)iter.next();<br />
entry.getKey();<br />
entry.getValue();<br />
}<br />
}</font></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zye.me/2011/09/3895.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>哈工大分词java接口</title>
		<link>http://blog.zye.me/2011/09/3894.html</link>
		<comments>http://blog.zye.me/2011/09/3894.html#comments</comments>
		<pubDate>Mon, 12 Sep 2011 16:28:10 +0000</pubDate>
		<dc:creator>yezheng</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[NLP]]></category>
		<category><![CDATA[信息检索]]></category>
		<category><![CDATA[分词]]></category>

		<guid isPermaLink="false">http://www.5yiso.cn/articles/%e5%93%88%e5%b7%a5%e5%a4%a7%e5%88%86%e8%af%8djava%e6%8e%a5%e5%8f%a3.html</guid>
		<description><![CDATA[ package IRdll; import java.io.File; import java.io.Reader; import java.io.FileInputStream; import java.io.*; import java.util.Date; import java.util.HashSet;/** * &#60;p&#62;Title: Java中文分词接口&#60;/p&#62; * &#60;p&#62;Description: 本组件以哈工大分词系统为基础，在其基础之上开发 * 本组件仅供学习和研究用途，任何商业用途将自行承担法律后果，与组件编写人无关。&#60;/p&#62; * &#60;p&#62;Copyright: Copyright (c) 2006&#60;/p&#62; * &#60;p&#62;Company: dalian univercity of techology&#60;/p&#62; * @author ：yezheng * @version 1.0 */ public class IRSplit { private static IRSplit instance = null; //instance时类中一成员，所以可以访问其中被private修饰的变量或方法 private static StringBuffer stringb <a href='http://blog.zye.me/2011/09/3894.html'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><span style="font-family: Verdana;"> package IRdll;</span></p>
<p><span style="font-family: Verdana;"><br />
import java.io.File;<br />
import java.io.Reader;<br />
import java.io.FileInputStream;<br />
import java.io.*;<br />
import java.util.Date;<br />
import java.util.HashSet;</span><span style="font-family: Verdana;">/**<br />
* &lt;p&gt;Title: Java中文分词接口&lt;/p&gt;<br />
* &lt;p&gt;Description: 本组件以哈工大分词系统为基础，在其基础之上开发<br />
* 本组件仅供学习和研究用途，任何商业用途将自行承担法律后果，与组件编写人无关。&lt;/p&gt;<br />
* &lt;p&gt;Copyright: Copyright (c) 2006&lt;/p&gt;<br />
* &lt;p&gt;Company: dalian univercity of techology&lt;/p&gt;<br />
* @author ：yezheng<br />
* @version 1.0<br />
*/</span></p>
<p>public class IRSplit {</p>
<p>private static IRSplit instance = null; //instance时类中一成员，所以可以访问其中被private修饰的变量或方法<br />
private static StringBuffer stringb = new StringBuffer(102400);<br />
private static StringBuffer longSentence = new StringBuffer(10240);</p>
<p>//私有构造方法<br />
private IRSplit() {<br />
System.out.println(&#8220;正在加载词典……&#8221;);<br />
this.LoadSegRes();<br />
System.out.println(&#8220;加载结束&#8221;);<br />
}</p>
<p>//获得一个实例<br />
public static IRSplit getInstance() {<br />
if (instance == null) {<br />
instance = new IRSplit();<br />
}<br />
return instance;<br />
}</p>
<p>//本地方法<br />
private native void LoadSegRes();</p>
<p>private native void ReleaseSegger();</p>
<p>private native String split(String sentence);</p>
<p>//对一句话分词<br />
public String splitSentence(String sentence) {<br />
if (sentence.length() &lt; 1 || sentence == null)<br />
return &#8220;&#8221;;<br />
else<br />
return split(sentence);<br />
}</p>
<p>public String splitLongSentence(String sentence) {<br />
if (sentence.length() &lt; 1 || sentence == null)<br />
return &#8220;&#8221;;<br />
else<br />
{<br />
this.longSentence.setLength(0);<br />
int start = 0 ; int  end = 0;<br />
for (int i = 0; i &lt; sentence.length(); i++)<br />
{<br />
char c = sentence.charAt(i);<br />
switch (Character.getType(c))<br />
{<br />
case 24:<br />
end++;<br />
//System.out.println(sentence.substring(start, end));<br />
this.longSentence.append(split(sentence.substring(start, end)));<br />
start = end;<br />
break;<br />
default:<br />
end++;<br />
break;<br />
}<br />
}<br />
if(start &lt; end)<br />
{<br />
longSentence.append(split(sentence.substring(start, end)));<br />
}<br />
return longSentence.toString();<br />
}<br />
}</p>
<p>public void ReleaseSeggers() {<br />
instance = null;<br />
ReleaseSegger();<br />
}</p>
<p>//对一个文件分词<br />
public void splitFile(File file, File outfile) {<br />
try {<br />
FileInputStream fis = new FileInputStream(file);<br />
BufferedReader br = new BufferedReader(new InputStreamReader(fis));<br />
this.stringb.setLength(0);<br />
String ts;<br />
while ( (ts = br.readLine()) != null) {<br />
if (ts.length() != 0) {<br />
stringb.append(splitLongSentence(ts) + &#8216;r&#8217; + &#8216;n&#8217;); //进行分词<br />
}<br />
else {<br />
stringb.append(&#8216;r&#8217;);<br />
stringb.append(&#8216;n&#8217;);<br />
}<br />
}<br />
br.close();<br />
fis.close();</p>
<p>FileWriter writer = new FileWriter(outfile);<br />
writer.write(stringb.toString());<br />
writer.close();<br />
}<br />
catch (FileNotFoundException ex) {<br />
System.out.println(file.toString() + &#8220;File not Found&#8221;);<br />
}<br />
catch (IOException ex1) {<br />
System.out.println(file.toString() + &#8220;IO errors&#8221;);<br />
}<br />
}</p>
<p>public void splitFile(String source, String destination) {<br />
File file = new File(source);<br />
File outfile = new File(destination);<br />
if (file.isFile()) {<br />
splitFile(file, outfile);<br />
}<br />
}</p>
<p>public Reader splitFile(Reader reader) {<br />
BufferedReader br = new BufferedReader(reader);<br />
StringBuffer stringb = new StringBuffer();</p>
<p>try {<br />
String ts;<br />
while ( (ts = br.readLine()) != null) {<br />
if (ts.length() != 0) {<br />
stringb.append(splitSentence(ts) + &#8216;r&#8217; + &#8216;n&#8217;); //进行分词<br />
}<br />
else {<br />
stringb.append(&#8216;r&#8217;);<br />
stringb.append(&#8216;n&#8217;);<br />
}<br />
}<br />
reader = new StringReader(stringb.toString());<br />
}<br />
catch (IOException ex) {<br />
}<br />
return reader;<br />
}</p>
<p>//处理一个目录下的所有文件<br />
public void splitFiles(String sourceDir, String destinationDir) { //参数：源文件目录和目标文件目录<br />
File directory = new File(sourceDir);<br />
File dirdes = new File(destinationDir);<br />
//FilenameFilter txtFilter = new myFilter(&#8220;txt&#8221;);<br />
File files[] = directory.listFiles();<br />
for (int i = 0; i &lt; files.length; i++) {<br />
if (files[i].isFile()) {<br />
File outfile = new File(destinationDir + &#8220;/&#8221; +<br />
files[i].getName());<br />
//System.out.println(directory.getName() + &#8220;:&#8221; + dirdes.getName());<br />
splitFile(files[i], outfile);<br />
}<br />
else if (files[i].isDirectory()) {</p>
<p>File tempdir = new File(destinationDir + &#8220;/&#8221; + files[i].getName());<br />
if (!tempdir.exists() || !tempdir.isDirectory()) {<br />
tempdir.mkdir();<br />
}<br />
splitFiles(sourceDir + &#8220;/&#8221; + files[i].getName(),<br />
tempdir.getAbsolutePath());<br />
}<br />
}<br />
}</p>
<p>static {<br />
System.loadLibrary(&#8220;IRdll&#8221;);<br />
}</p>
<p>public static void main(String[] args) {</p>
<p>IRSplit split = IRSplit.getInstance(); //其它类使用</p>
<p>long start = System.currentTimeMillis();<br />
Date startdate = new Date();</p>
<p>//split.splitFiles(&#8220;clean&#8221;, &#8220;out&#8221;);<br />
split.splitLongSentence(ss);</p>
<p>Date enddate = new Date();</p>
<p>System.out.println(startdate);<br />
System.out.println(enddate);<br />
System.out.println(enddate.getTime()- startdate.getTime());<br />
}</p>
<p>}</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zye.me/2011/09/3894.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>java中的基本数值类型</title>
		<link>http://blog.zye.me/2011/08/49376.html</link>
		<comments>http://blog.zye.me/2011/08/49376.html#comments</comments>
		<pubDate>Thu, 11 Aug 2011 14:29:25 +0000</pubDate>
		<dc:creator>yezheng</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.so8848.com/2009/02/49376.html</guid>
		<description><![CDATA[java中的基本数值类型，如下表： &#160; Primitive type Size Minimum Maximum Wrapper type boolean — — — Boolean char 16-bit Unicode 0 Unicode 216- 1 Character byte  8-bit -128 +127 Byte short 16-bit -215 +215—1 Short int 32-bit -231 +231—1 Integer long 64-bit -263 +263—1 Long float 32-bit IEEE754 IEEE754 Float double 64-bit  IEEE754 IEEE754 Double void — — <a href='http://blog.zye.me/2011/08/49376.html'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><span style="font-family: verdana; font-size: 12px; line-height: 18px" class="Apple-style-span"></p>
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px"><span style="font-weight: bold" class="Apple-style-span">java中的基本数值类型</span>，如下表：</p>
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px">&nbsp;</p>
<table border="1">
<tr valign="top">
<th width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>Primitive type</strong></p>
</th>
<th width="59" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>Size</strong></p>
</th>
<th width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>Minimum</strong></p>
</th>
<th width="113" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>Maximum</strong></p>
</th>
<th width="103" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>Wrapper type</strong></p>
</th>
</tr>
<tr valign="top">
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>boolean</strong></p>
</td>
<td width="59" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">—</p>
</td>
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">—</p>
</td>
<td width="113" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">—</p>
</td>
<td width="103" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>Boolean</strong></p>
</td>
</tr>
<tr valign="top">
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>char</strong></p>
</td>
<td width="59" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">16-bit</p>
</td>
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">Unicode 0</p>
</td>
<td width="113" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">Unicode 2<sup>16</sup>- 1</p>
</td>
<td width="103" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>Character</strong></p>
</td>
</tr>
<tr valign="top">
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>byte </strong></p>
</td>
<td width="59" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">8-bit</p>
</td>
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">-128</p>
</td>
<td width="113" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">+127</p>
</td>
<td width="103" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>Byte</strong></p>
</td>
</tr>
<tr valign="top">
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>short</strong></p>
</td>
<td width="59" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">16-bit</p>
</td>
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">-2<sup>15</sup></p>
</td>
<td width="113" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">+2<sup>15</sup>—1</p>
</td>
<td width="103" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>Short</strong></p>
</td>
</tr>
<tr valign="top">
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>int</strong></p>
</td>
<td width="59" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">32-bit</p>
</td>
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">-2<sup>31</sup></p>
</td>
<td width="113" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">+2<sup>31</sup>—1</p>
</td>
<td width="103" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>Integer</strong></p>
</td>
</tr>
<tr valign="top">
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>long</strong></p>
</td>
<td width="59" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">64-bit</p>
</td>
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">-2<sup>63</sup></p>
</td>
<td width="113" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">+2<sup>63</sup>—1</p>
</td>
<td width="103" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>Long</strong></p>
</td>
</tr>
<tr valign="top">
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>float</strong></p>
</td>
<td width="59" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">32-bit</p>
</td>
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">IEEE754</p>
</td>
<td width="113" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">IEEE754</p>
</td>
<td width="103" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>Float</strong></p>
</td>
</tr>
<tr valign="top">
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>double</strong></p>
</td>
<td width="59" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">64-bit </p>
</td>
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">IEEE754</p>
</td>
<td width="113" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">IEEE754</p>
</td>
<td width="103" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>Double</strong></p>
</td>
</tr>
<tr valign="top">
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>void</strong></p>
</td>
<td width="59" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">—</p>
</td>
<td width="95" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">—</p>
</td>
<td width="113" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table">—</p>
</td>
<td width="103" valign="top">
<p style="margin-top: 1em; margin-right: 0px; margin-bottom: 0.5em; margin-left: 0px; text-indent: 2em; line-height: 22px; font-size: 14px; padding: 0px" class="Table"><strong>Void</strong></p>
</td>
</tr>
</table>
<p></span></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zye.me/2011/08/49376.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>private 变量继承问题</title>
		<link>http://blog.zye.me/2011/08/45098.html</link>
		<comments>http://blog.zye.me/2011/08/45098.html#comments</comments>
		<pubDate>Thu, 04 Aug 2011 14:27:32 +0000</pubDate>
		<dc:creator>yezheng</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[private变量]]></category>
		<category><![CDATA[子类]]></category>

		<guid isPermaLink="false">http://www.5yiso.cn/2008/12/45098.html</guid>
		<description><![CDATA[核心一点，子类中不能访问父类的private 变量，但可以通过机场父类的public方法简介访问。 这是否也意味着private属性能被继承，这个逻辑上感觉有点混乱。 我比较认同的说法是： private限制访问方式只能在类，的内部,&#160;&#160; 这仅仅是一个访问控制,&#160;&#160; 实际上子类对象拥有父类对象的一切. &#160; 不过无所谓了，细节上争论没什么意思，知道怎么回事怎么用就可以了。]]></description>
			<content:encoded><![CDATA[</p>
<p>核心一点，子类中不能访问父类的private 变量，但可以通过机场父类的public方法简介访问。</p>
<p>这是否也意味着private属性能被继承，这个逻辑上感觉有点混乱。</p>
<p>我比较认同的说法是：</p>
<p>private限制访问方式只能在类，的内部,&nbsp;&nbsp; 这仅仅是一个访问控制,&nbsp;&nbsp; 实际上子类对象拥有父类对象的一切.</p>
<p>&nbsp;</p>
<p>不过无所谓了，细节上争论没什么意思，知道怎么回事怎么用就可以了。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zye.me/2011/08/45098.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>子类构造方法执行过程</title>
		<link>http://blog.zye.me/2011/08/45097.html</link>
		<comments>http://blog.zye.me/2011/08/45097.html#comments</comments>
		<pubDate>Wed, 03 Aug 2011 14:27:40 +0000</pubDate>
		<dc:creator>yezheng</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[子类]]></category>
		<category><![CDATA[构造方法]]></category>

		<guid isPermaLink="false">http://www.5yiso.cn/2008/12/45097.html</guid>
		<description><![CDATA[譬如有两个类ChineseTokenizing&#160; 和 FixedWeightEditDistance 其中 ChineseTokenizing extends FixedWeightEditDistance 那么ChineseTokenizing 中的构造方法不管是否有参数，执行时都是首先调用父类FixedWeightEditDistance的无参数构造方法，然后再执行ChineseTokenizing 构造方法中的语句。当然如果ChineseTokenizing 的构造方法如果显示调用了super，就另当别论了。跟踪下会很清楚 另外如果父类中只有一个private构造方法，则该类无法继承，因为无法在子类中调用。]]></description>
			<content:encoded><![CDATA[<p>譬如有两个类ChineseTokenizing&nbsp; 和 FixedWeightEditDistance</p>
<p>其中 ChineseTokenizing extends FixedWeightEditDistance</p>
<p>那么ChineseTokenizing 中的构造方法不管是否有参数，执行时都是首先调用父类FixedWeightEditDistance的无参数构造方法，然后再执行ChineseTokenizing 构造方法中的语句。当然如果ChineseTokenizing 的构造方法如果显示调用了super，就另当别论了。跟踪下会很清楚</p>
<p>另外如果父类中只有一个private构造方法，则该类无法继承，因为无法在子类中调用。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zye.me/2011/08/45097.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JAVA入门教程: 第 四 章 流 控 制</title>
		<link>http://blog.zye.me/2011/07/27203.html</link>
		<comments>http://blog.zye.me/2011/07/27203.html#comments</comments>
		<pubDate>Sat, 30 Jul 2011 02:27:26 +0000</pubDate>
		<dc:creator>yezheng</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[信息检索]]></category>

		<guid isPermaLink="false">http://www.5yiso.cn/2008/04/27203.html</guid>
		<description><![CDATA[与 C、 C++相 同 ,Java程 序 通 过 流 控 制 来 执 行 程 序 流 ,完 成 一 定 的 任 务 。 程 序 流 是 由 若 干 个 语 句 组 成 的 。 语 句 可 以 是 单 一 的 一 条 语 句 ( 如 c=a+b; ),也 <a href='http://blog.zye.me/2011/07/27203.html'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><font color="#000000">与 C、 C++相 同 ,Java程 序 通 过 流 控 制 来 执 行 程 序 流 ,完 成 一 定 的 任 务 。 程 序 流 是 由 若 干<br />
<br />个 语 句 组 成 的 。 语 句 可 以 是 单 一 的 一 条 语 句 ( 如 c=a+b; ),也 可 以 是 用 大 括 号 {}括 起 来 的 一 个<br />
<br />复 合 语 句 。</p>
<p>下 面 我 们 分 别 来 介 绍 Java中 的 流 控 制 语 句 ,包 括</p>
<p>1.分 支 语 句 :if-else, break, switch, return.</p>
<p>2.循 环 语 句 :while, do-while, for, continue.</p>
<p>3.例 外 处 理 语 句 :try-catch-finally, throw</p>
<p>最 后 我 们 简 单 介 绍 一 下 注 释 语 句 。</p>
<p>§ 4.1分 支 语 句</p>
<p>分 支 语 句 提 供 了 一 种 控 制 机 制 ,使 得 程 序 的 执 行 可 以 跳 过 某 些 语 句 不 执 行 ,而 转 去 执<br />
<br />行 特 定 的 语 句 。</p>
<p>4.1.1条 件 语 句 if-else.</p>
<p>if-else语 句 根 据 判 定 条 件 的 真 假 来 执 行 两 种 操 作 中 的 一 种 , 它 的 格 式 为 :</p>
<p>if(boolean-expression)<br />
<br />statement1;<br />
<br />[else<br />
<br />statement2;]</p>
<p>1.布 尔 表 达 式 boolean-expression是 任 意 一 个 返 回 布 尔 型 数 据 的 表 达 式 (这 比 C、 C++的 限 制<br />
<br />要 严 格 )。</p>
<p>2.每 个 单 一 的 语 句 后 都 必 须 有 分 号 。</p>
<p>3.语 句 statement1,statement2可 以 为 复 合 语 句 ,这 时 要 用 大 括 号 {} 括 起 。 建 议 对 单 一 的 语 句<br />
<br />也 用 大 括 号 括 起 ,这 样 程 序 的 可 读 性 强 ,而 且 有 利 于 程 序 的 扩 充 (可 以 在 其 中 填 加 新 的 语 句<br />
<br />)。 {}外 面 不 加 分 号 。</p>
<p>4.else子 句 是 任 选 的 。</p>
<p>5.若 布 尔 表 达 式 的 值 为 true,则 程 序 执 行 statement1,否 则 执 行 st atement2。</p>
<p>6.if-else语 句 的 一 种 特 殊 形 式 为 :</p>
<p>if(expression1){<br />
<br />statement1<br />
<br />}else if (expression2){<br />
<br />statement2<br />
<br />}……<br />
<br />}else if (expressionM){<br />
<br />statementM<br />
<br />}else {<br />
<br />statementN<br />
<br />}<br />
<br />@@@[<br />
<br />else子句不能单独作为语句使用,它必须和if配对使用。else总是与离它最近的if配对<br />
<br />。可以通过使用大括号{}来改变配对关系。<br />
<br />7.举例:<br />
<br />例4.1 比较两个数的大小,并按从小到大的次序输出。<br />
<br />@@@[<br />
<br />public class CompareTwo{<br />
<br />public static void main( String args[] ){<br />
<br />double d1=23.4;<br />
<br />double d2=35.1;<br />
<br />if(d2＞=d1)<br />
<br />System.out.println(d2+&#8221; ＞= &#8220;+d1);<br />
<br />else<br />
<br />System.out.println(d1+&#8221; ＞= &#8220;+d2);<br />
<br />}<br />
<br />}<br />
<br />运行结果为:<br />
<br />C:＞java CompareTwo</p>
<p>35.1 ＞= 23.4</p>
<p>例 4.2 判 断 某 一 年 是 否 为 闰 年 。</p>
<p>闰 年 的 条 件 是 符 合 下 面 二 者 之 一 :① 能 被 4整 除 ,但 不 能 被 10 0整 除 ;② 能 被 4整 除 ,又 能 被<br />
<br />100整 除 。</p>
<p>public class LeapYear{<br />
<br />public static void main( String args[] ){<br />
<br />int year=1989; //method 1<br />
<br />if( (year%4==0 &amp;amp;&amp;amp; year%100!=0) || (year%400==0) )<br />
<br />System.out.println(year+&#8221; is a leap year.&#8221;);<br />
<br />else<br />
<br />System.out.println(year+&#8221; is not a leap year.&#8221;);<br />
<br />year=2000; //method 2<br />
<br />boolean leap;<br />
<br />if( year%4!=0 )<br />
<br />leap=false;<br />
<br />else if( year%100!=0 )<br />
<br />leap=true;<br />
<br />else if( year%400!=0 )<br />
<br />leap=false;<br />
<br />else<br />
<br />leap=true;<br />
<br />if( leap==true )<br />
<br />System.out.println(year+&#8221; is a leap year.&#8221;);<br />
<br />else<br />
<br />System.out.println(year+&#8221; is not a leap year.&#8221;);<br />
<br />year=2050; //method3<br />
<br />if( year%4==0){<br />
<br />if( year%100==0 ){<br />
<br />if( year%400==0)<br />
<br />leap=true;<br />
<br />else<br />
<br />leap=false;<br />
<br />}else<br />
<br />leap=false;<br />
<br />}else<br />
<br />leap=false;<br />
<br />if( leap==true )<br />
<br />System.out.println(year+&#8221; is a leap year.&#8221;);<br />
<br />else<br />
<br />System.out.println(year+&#8221; is not a leap year.&#8221;);<br />
<br />}<br />
<br />}<br />
<br />运行结果为<br />
<br />C:＞java LeapYear<br />
<br />1989 is not a leap year.<br />
<br />2000 is a leap year.<br />
<br />2050 is not a leap year.</p>
<p>该 例 中 ,方 法 1用 一 个 逻 辑 表 达 式 包 含 了 所 有 的 闰 年 条 件 ,方 法 2使 用 了 if-else语 句 的 特 殊<br />
<br />形 式 ,方 法 3则 通 过 使 用 大 括 号 {}对 if-else进 行 匹 配 来 实 现 闰 年 的 判 断 。 大 家 可 以 根 据 程 序 来<br />
<br />对 比 这 三 种 方 法 ,体 会 其 中 的 联 系 和 区 别 ,在 不 同 的 场 合 选 用 适 合 的 方 法 。</p>
<p>4.1.2多 分 支 语 句 switch</p>
<p>switch 语 句 根 据 表 达 式 的 值 来 执 行 多 个 操 作 中 的 一 个 ,它 的 一 般 格 式 如 下 :</p>
<p>switch (expression){<br />
<br />case value1 : statement1;<br />
<br />break;<br />
<br />case value2 : statement2;<br />
<br />break;<br />
<br />…………<br />
<br />case valueN : statemendN;<br />
<br />break;<br />
<br />[default : defaultStatement; ]<br />
<br />}</p>
<p>1.表 达 式 expression可 以 返 回 任 一 简 单 类 型 的 值 (如 整 型 、 实 型 、 字 符 型 ),多 分 支 语 句 把<br />
<br />表 达 式 返 回 的 值 与 每 个 case子 句 中 的 值 相 比 。 如 果 匹 配 成 功 ,则 执 行 该 case子 句 后 的 语 句 序<br />
<br />列 。</p>
<p>2.case子 句 中 的 值 valueI必 须 是 常 量 ,而 且 所 有 case子 句 中 的 值 应 是 不 同 的 。</p>
<p>3.default子 句 是 任 选 的 。 当 表 达 式 的 值 与 任 一 case子 句 中 的 值 都 不 匹 配 时 ,程 序 执 行<br />
<br />default后 面 的 语 句 。 如 果 表 达 式 的 值 与 任 一 case子 句 中 的 值 都 不 匹 配 且 没 有 default子 句 ,则 程<br />
<br />序 不 作 任 何 操 作 ,而 是 直 接 跳 出 switch语 句 。</p>
<p>4.break语 句 用 来 在 执 行 完 一 个 case分 支 后 ,使 程 序 跳 出 switch语 句 ,即 终 止 switch语 句 的 执 行<br />
<br />。 因 为 case子 句 只 是 起 到 一 个 标 号 的 作 用 ,用 来 查 找 匹 配 的 入 口 并 从 此 处 开 始 执 行 ,对 后 面<br />
<br />的 case子 句 不 再 进 行 匹 配 ,而 是 直 接 执 行 其 后 的 语 句 序 列 , 因 此 应 该 在 每 个 case分 支 后 ,要 用<br />
<br />break来 终 止 后 面 的 case分 支 语 句 的 执 行 。</p>
<p>在 一 些 特 殊 情 况 下 ,多 个 不 同 的 case值 要 执 行 一 组 相 同 的 操 作 ,这 时 可 以 不 用 break。</p>
<p>5.case分 支 中 包 括 多 个 执 行 语 句 时 ,可 以 不 用 大 括 号 {}括 起 。</p>
<p>6.switch语 句 的 功 能 可 以 用 if-else来 实 现 ,但 在 某 些 情 况 下 ,使 用 switch语 句 更 简 炼 ,可 读 性 强<br />
<br />,而 且 程 序 的 执 行 效 率 提 高 。</p>
<p>7.举 例 :</p>
<p>例 4.3.根 据 考 试 成 绩 的 等 级 打 印 出 百 分 制 分 数 段 。</p>
<p>public class GradeLevel{<br />
<br />public static void main( String args[] ){<br />
<br />System.out.println(&#8220;n** first situation **&#8221;);<br />
<br />char grade=&#8217;C'; //normal use<br />
<br />switch( grade ){<br />
<br />case &#8216;A&#8217; : System.out.println(grade+&#8221; is 85～100&#8243;);<br />
<br />break;<br />
<br />case &#8216;B&#8217; : System.out.println(grade+&#8221; is 70～84&#8243;);<br />
<br />break;<br />
<br />case &#8216;C&#8217; : System.out.println(grade+&#8221; is 60～69&#8243;);<br />
<br />break;<br />
<br />case &#8216;D&#8217; : System.out.println(grade+&#8221; is ＜60&#8243;);<br />
<br />break;<br />
<br />default : System.out.println(&#8220;input error&#8221;);<br />
<br />}<br />
<br />System.out.println(&#8220;n** second situation **&#8221;);<br />
<br />grade=&#8217;A'; ∥creat error without break statement<br />
<br />switch( grade ){<br />
<br />case &#8216;A&#8217; : System.out.println(grade+&#8221; is 85～100&#8243;);<br />
<br />case &#8216;B&#8217; : System.out.println(grade+&#8221; is 70～84&#8243;);<br />
<br />case &#8216;C&#8217; : System.out.println(grade+&#8221; is 60～69&#8243;);<br />
<br />case &#8216;D&#8217; : System.out.println(grade+&#8221; is ＜60&#8243;);<br />
<br />default : System.out.println(&#8220;input error&#8221;);<br />
<br />}<br />
<br />System.out.println(&#8220;n** third situation **&#8221;);<br />
<br />grade=&#8217;B'; ∥several case with same operation<br />
<br />switch( grade ){<br />
<br />case &#8216;A&#8217; :<br />
<br />case &#8216;B&#8217; :<br />
<br />case &#8216;C&#8217; : System.out.println(grade+&#8221; is ＞=60&#8243;);<br />
<br />break;<br />
<br />case &#8216;D&#8217; : System.out.println(grade+&#8221; is ＜60&#8243;);<br />
<br />break;<br />
<br />default : System.out.println(&#8220;input error&#8221;);<br />
<br />}<br />
<br />}<br />
<br />}<br />
<br />运行结果为<br />
<br />C:＞java GradeLevel<br />
<br />**** first situation ****<br />
<br />C is 60～69<br />
<br />**** second situation ****<br />
<br />A is 85～100<br />
<br />A is 70～84<br />
<br />A is 60～69<br />
<br />A is ＜60<br />
<br />input error<br />
<br />**** third situation ****<br />
<br />B is ＞=60</p>
<p>从 该 例 中 我 们 可 以 看 到 break语 句 的 作 用 。</p>
<p>4.1.3 break语 句</p>
<p>1.在 switch语 中 ,break语 句 用 来 终 止 switch语 句 的 执 行 。 使 程 序 从 switch语 句 后 的 第 一 个 语 句<br />
<br />开 始 执 行 。</p>
<p>2.在 Java中 ,可 以 为 每 个 代 码 块 加 一 个 括 号 ,一 个 代 码 块 通 常 是 用 大 括 号 {}括 起 来 的 一 段<br />
<br />代 码 。 加 标 号 的 格 式 如 下 :</p>
<p>BlockLabel: { codeBlock }</p>
<p>break语 句 的 第 二 种 使 用 情 况 就 是 跳 出 它 所 指 定 的 块 ,并 从 紧 跟 该 块 的 第 一 条 语 句 处 执<br />
<br />行 。 其 格 式 为 :</p>
<p>break BlockLabel;<br />
<br />例如:<br />
<br />a:{…… //标记代码块a<br />
<br />b: {…… //标记代码块b<br />
<br />c: {…… //标记代码块c<br />
<br />break b;<br />
<br />…… //will not be executed<br />
<br />}<br />
<br />…… //will not be executed<br />
<br />}<br />
<br />…… /execute from here<br />
<br />}</p>
<p>3.与 C、 C++不 同 ,Java中 没 有 goto语 句 来 实 现 任 意 的 跳 转 ,因 为 g oto语 句 破 坏 程 序 的 可 读 性<br />
<br />,而 且 影 响 编 译 的 优 化 。 但 是 从 上 例 可 以 看 出 ,Java用 break来 实 现 goto语 句 所 特 有 的 一 些 优 点<br />
<br />。 如 果 break后 所 指 定 的 标 号 不 是 一 个 代 码 块 的 标 号 ,而 是 一 个 语 句 ,则 这 时 break完 全 实 现<br />
<br />goto的 功 能 。 不 过 应 该 避 免 这 种 方 式 的 使 用 。 　  (未 完 待 续 )<br />
<br />4.1.4返 回 语 句 return</p>
<p>return语 句 从 当 前 方 法 中 退 出 ,返 回 到 调 用 该 方 法 的 语 句 处 , 并 从 紧 跟 该 语 句 的 下 一 条 语<br />
<br />句 继 续 程 序 的 执 行 。 (有 关 方 法 的 内 容 ,我 们 将 在 第 六 章 详 细 讲 述 。 前 面 例 子 中 的 main( )就<br />
<br />是 一 个 方 法 )。 返 回 语 句 有 两 种 格 式 :</p>
<p>1.return expression</p>
<p>返 回 一 个 值 给 调 用 该 方 法 的 语 句 ,返 回 值 的 数 据 类 型 必 须 和 方 法 声 明 中 的 返 回 值 类 型<br />
<br />一 致 。 可 以 使 用 强 制 类 型 转 换 来 使 类 型 一 致 。</p>
<p>2.return</p>
<p>当 方 法 说 明 中 用 void声 明 返 回 类 型 为 空 时 ,应 使 用 这 种 格 式 ,它 不 返 回 任 何 值 。</p>
<p>return 语 句 通 常 用 在 一 个 方 法 体 的 最 后 ,以 退 出 该 方 法 并 返 回 一 个 值 。 Java中 ,单 独 的<br />
<br />return语 句 用 在 一 个 方 法 体 的 中 间 时 ,会 产 生 编 译 错 误 ,因 为 这 时 会 有 一 些 语 句 执 行 不 到 。 但<br />
<br />可 以 通 过 把 return语 句 嵌 入 某 些 语 句 (如 if-else)来 使 程 序 在 未 执 行 完 方 法 中 的 所 有 语 句 时 退 出<br />
<br />,例 如 :</p>
<p>int method (int num) {<br />
<br />∥ return num; ∥will cause compile time error<br />
<br />if (num＞0)<br />
<br />return num;<br />
<br />……　∥ may or may not be executed<br />
<br />∥depending on the value of num</p>
<p>§ 4.2循 环 语 句</p>
<p>循 环 语 句 的 作 用 是 反 复 执 行 一 段 代 码 ,直 到 满 足 终 止 循 环 的 条 件 为 止 ,一 个 循 环 一 般<br />
<br />应 包 括 四 部 分 内 容 :</p>
<p>1.初 始 化 部 分 (initialization):用 来 设 置 循 环 的 一 些 初 始 条 件 , 如 计 数 器 清 零 等 。</p>
<p>2.循 环 体 部 分 (body):这 是 反 复 循 环 的 一 段 代 码 ,可 以 是 单 一 的 一 条 语 句 ,也 可 以 是 复 合 语<br />
<br />句 。</p>
<p>3.迭 代 部 分 (iteration):这 是 在 当 前 循 环 结 束 ,下 一 次 循 环 开 始 前 执 行 的 语 句 ,常 常 用 来 使 计<br />
<br />数 器 加 1或 减 1。</p>
<p>4.终 止 部 分 (termination):通 常 是 一 个 布 尔 表 达 式 ,每 一 次 循 环 都 要 对 该 表 达 式 求 值 ,以 验 证<br />
<br />是 否 满 足 循 环 终 止 条 件 。</p>
<p>Java中 提 供 的 循 环 语 句 有 :while语 句 ,do-while语 句 和 for语 句 ,下 面 分 别 介 绍 。</p>
<p>4.2.1while语 句</p>
<p>while语 句 实 现 &#8220;当 型 &#8220;循 环 ,它 的 一 般 格 式 为 ;</p>
<p>[initialization]<br />
<br />while (termination){<br />
<br />body;<br />
<br />[iteration;]<br />
<br />}</p>
<p>1.当 布 尔 表 达 式 (termination)的 值 为 true时 ,循 环 执 行 大 括 号 中 的 语 句 。 并 且 初 始 化 部 分 和<br />
<br />迭 代 部 分 是 任 选 的 。</p>
<p>2.while语 句 首 先 计 算 终 止 条 件 ,当 条 件 满 足 时 ,才 去 执 行 循 环 体 中 的 语 句 。 这 是 &#8220;当 型 &#8220;循<br />
<br />环 的 特 点 。</p>
<p>4.2.2 do-while语 句</p>
<p>do-while 语句实现&#8221;直到型&#8221;循环,它的一般格式为:<br />
<br />[initialization]<br />
<br />do {<br />
<br />body;<br />
<br />[iteration;]<br />
<br />} while (termination);</p>
<p>1.do-while语 句 首 先 执 行 循 环 体 ,然 后 计 算 终 止 条 件 ,若 结 果 为 true,则 循 环 执 行 大 括 号 中 的<br />
<br />语 句 ,直 到 布 尔 表 达 式 的 结 果 为 false。</p>
<p>2.与 while语 句 不 同 的 是 ,do-while语 句 的 循 环 体 至 少 执 行 一 次 , 这 是 &#8220;直 到 型 &#8220;循 环 的 特 点 。</p>
<p>4.2.3 for语 句</p>
<p>for语 句 也 用 来 实 现 &#8220;当 型 &#8220;循 环 ,它 的 一 般 格 式 为 :</p>
<p>for (initialization; termination; iteration){</p>
<p>body;</p>
<p>}</p>
<p>1.for语 句 执 行 时 ,首 先 执 行 初 始 化 操 作 ,然 后 判 断 终 止 条 件 是 否 满 足 ,如 果 满 足 ,则 执 行 循<br />
<br />环 体 中 的 语 句 ,最 后 执 行 迭 代 部 分 。 完 成 一 次 循 环 后 ,重 新 判 断 终 止 条 件 。</p>
<p>2.可 以 在 for语 句 的 初 始 化 部 分 声 明 一 个 变 量 ,它 的 作 用 域 为 整 个 for 语 句 。</p>
<p>3.for语 句 通 常 用 来 执 行 循 环 次 数 确 定 的 情 况 (如 对 数 组 元 素 进 行 操 作 ),也 可 以 根 据 循 环<br />
<br />结 束 条 件 执 行 循 环 次 数 不 确 定 的 情 况 。</p>
<p>4.在 初 始 化 部 分 和 迭 代 部 分 可 以 使 用 逗 号 语 句 ,来 进 行 多 个 操 作 。 逗 号 语 句 是 用 逗 号<br />
<br />分 隔 的 语 句 序 列 。 例 如 :</p>
<p>for( i=0, j=10; i＜j; i++, j&#8211;){<br />
<br />……<br />
<br />}</p>
<p>5.初 始 化 、 终 止 以 及 迭 代 部 分 都 可 以 为 空 语 句 (但 分 号 不 能 省 ),三 者 均 为 空 的 时 候 ,相<br />
<br />当 于 一 个 无 限 循 环 。</p>
<p>4.2.4 continue语 句</p>
<p>1.continue语 句 用 来 结 束 本 次 循 环 ,跳 过 循 环 体 中 下 面 尚 未 执 行 的 语 句 ,接 着 进 行 终 止 条<br />
<br />件 的 判 断 ,以 决 定 是 否 继 续 循 环 。 对 于 for语 句 ,在 进 行 终 止 条 件 的 判 断 前 ,还 要 先 执 行 迭 代<br />
<br />语 句 。 它 的 格 式 为 :</p>
<p>continue;</p>
<p>2.也 可 以 用 continue跳 转 到 括 号 指 明 的 外 层 循 环 中 ,这 时 的 格 式 为</p>
<p>continue outerLable;</p>
<p>例 如 :</p>
<p>outer: for( int i=0; i＜10; i++ ){ ∥外层循环<br />
<br />for( int j=0; j＜20; j++ ){ ∥内层循环<br />
<br />if( j＞i ){<br />
<br />……<br />
<br />continue outer;<br />
<br />}<br />
<br />……<br />
<br />}<br />
<br />……<br />
<br />}</p>
<p>该 例 中 ,当 满 足 j＞i的 条 件 时 ,程 序 执 行 完 相 应 的 语 句 后 跳 转 到 外 层 循 环 ,执 行 外 层 循 环<br />
<br />的 迭 代 语 句 i++;然 后 开 始 下 一 次 循 环 。</p>
<p>4.2.5举 例</p>
<p>例 4.4 下 例 分 别 用 while、 do-while和 for语 句 实 现 累 计 求 和 。</p>
<p>public class Sum{<br />
<br />public static void main( String args[] ){<br />
<br />System.out.println(&#8220;n** while statement **&#8221;);<br />
<br />int n=10,sum=0; ∥initialization<br />
<br />while( n＞0 ){ ∥termination<br />
<br />sum+=n; ∥body<br />
<br />n&#8211;; ∥iteration<br />
<br />}<br />
<br />System.out.println(&#8220;sum is &#8220;+sum);<br />
<br />System.out.println(&#8220;n** do_while statement **&#8221;);<br />
<br />n=0; ∥initialization<br />
<br />sum=0;<br />
<br />do{<br />
<br />sum+=n; ∥body<br />
<br />n++; ∥iteration<br />
<br />}while( n＜=10 ); ∥termination<br />
<br />System.out.println(&#8220;sum is &#8220;+sum);<br />
<br />System.out.println(&#8220;n** for statement **&#8221;);<br />
<br />sum=0;<br />
<br />for( int i=1; i＜=10; i++){<br />
<br />∥initialization,termination,iteration<br />
<br />sum+=i;<br />
<br />}<br />
<br />System.out.println(&#8220;sum is &#8220;+sum);<br />
<br />}<br />
<br />}<br />
<br />运行结果为:<br />
<br />C:＞java Sum<br />
<br />** while statement **<br />
<br />sum is 55<br />
<br />** do_while statement **<br />
<br />sum is 55<br />
<br />** for statement **<br />
<br />sum is 55<br />
<br />可以从中来比较这三种循环语句,从而在不同的场合选择合适的语句。<br />
<br />例4.5 求100～200间的所有素数<br />
<br />public class PrimeNumber{<br />
<br />public static void main( String args[] ){<br />
<br />System.out.println(&#8221; ** prime numbers between 100 and 200 **&#8221;);<br />
<br />int n=0;<br />
<br />outer:for(int i=101;i＜200;i+=2){ ∥outer loop<br />
<br />int k=15; ∥select for convinence for(int j=2;j＜=k;j++){ ∥inner loop<br />
<br />if( i%j==0 )<br />
<br />continue outer;<br />
<br />}<br />
<br />System.out.print(&#8221; &#8220;+i);<br />
<br />n++; ∥output a new line<br />
<br />if( n＜10 ) ∥after 10 numbers<br />
<br />continue;<br />
<br />System.out.println();<br />
<br />n=0;<br />
<br />}<br />
<br />System.out.println();<br />
<br />}<br />
<br />}<br />
<br />运行结果为:<br />
<br />C:＞java PrimeNumber<br />
<br />** prime numbers between 100 and 200 **<br />
<br />101 103 107 109 113 127 131 137 139 149<br />
<br />151 157 163 167 173 179 181 191 193 197<br />
<br />199</p>
<p>该 例 通 过 一 个 嵌 套 的 for语 句 来 实 现 。 !U4§ 4.3例 外 处 理 语 句</p>
<p>例 外 处 理 语 句 包 括 try、 catch、 finally以 及 throw语 句 。 与 C、 C+ +相 比 ,例 外 处 理 语 句 是<br />
<br />Java所 特 有 的 。 我 们 将 在 第 八 章 作 专 门 的 介 绍 。 !U4§ 4.4 注 释 语 句</p>
<p>Java中 可 以 采 用 三 种 注 释 方 式 :</p>
<p>1 ∥　用于单行注释。注释从∥开始,终止于行尾。<br />
<br />2 /* … */ 用于多行注释。注释从/*开始,到*/结束,且这种注释不能互相嵌套。<br />
<br />3 /** … */ 是Java所特有的doc注释。它以/**开始,到*/结束。这种注释主要是<br />
<br />为支持JDK工具javadoc而采用的。javadoc能识别注释中用标记@标识的一些特殊变量,并把<br />
<br />doc注释加入它所生成的HTML文件。对javadoc的详细讲述可参见附录。<br />
</font></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zye.me/2011/07/27203.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JAVA入门教程: 第 三 章 运算符和表达式</title>
		<link>http://blog.zye.me/2011/07/27201.html</link>
		<comments>http://blog.zye.me/2011/07/27201.html#comments</comments>
		<pubDate>Tue, 26 Jul 2011 02:28:03 +0000</pubDate>
		<dc:creator>yezheng</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.5yiso.cn/2008/04/27201.html</guid>
		<description><![CDATA[运 算 符 指 明 对 操 作 数 所 进 行 的 运 算 。 按 操 作 数 的 数 目 来 分 ,可 以 有 一 元 运 算 符 (如 ++、 -),二 元 运 算 符 (如 +、 ＞)和 三 元 运 算 符 (如 ?:),它 们 分 别 对 应 <a href='http://blog.zye.me/2011/07/27201.html'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p><font color="#000000">运 算 符 指 明 对 操 作 数 所 进 行 的 运 算 。 按 操 作 数 的 数 目 来 分 ,可 以 有 一 元 运 算 符 (如 ++、<br />
<br />-),二 元 运 算 符 (如 +、 ＞)和 三 元 运 算 符 (如 ?:),它 们 分 别 对 应 于 一 个 、 两 个 和 三 个 操 作 数 。 对<br />
<br />于 一 元 运 算 符 来 说 ,可 以 有 前 缀 表 达 式 (如 ++i )和 后 缀 表 达 式 (如 i++),对 于 二 元 运 算 符 来 说 则<br />
<br />采 用 中 缀 表 达 式 (如 a+b)。 按 照 运 算 符 功 能 来 分 ,基 本 的 运 算 符 有 下 面 几 类 :</p>
<p>1.算 术 运 算 符 (+,-,*,/,%,++,&#8211;)</p>
<p>2.关 系 运 算 符 (＞,＜,＞=,＜=,==,!=)</p>
<p>3.布 尔 逻 辑 运 算 符 (!,&amp;amp;&amp;amp;,||)</p>
<p>4.位 运 算 符 (＞＞,＜＜,＞＞＞,&amp;amp;,|,^,～ )</p>
<p>5.赋 值 运 算 符 (=,及 其 扩 展 赋 值 运 算 符 如 +=)</p>
<p>6.条 件 运 算 符 ( ?:)</p>
<p>7.其 它 (包 括 分 量 运 算 符 · ,下 标 运 算 符 [],实 例 运 算 符 instanc eof,内 存 分 配 运 算 符 new,强 制 类<br />
<br />型 转 换 运 算 符 (类 型 ),方 法 调 用 运 算 符 () 等 )</p>
<p>本 章 中 我 们 主 要 讲 述 前 6类 运 算 符 。</p>
<p>§ 3.1算 术 运 算 符</p>
<p>算 术 运 算 符 作 用 于 整 型 或 浮 点 型 数 据 ,完 成 算 术 运 算 。</p>
<p>一 、 二 元 算 术 运 算 符 ,如 下 表 所 示</p>
<p>运算符 用法 描述<br />
<br />+ op1+op2 加<br />
<br />- op1-op2 减<br />
<br />* op1*op2 乘<br />
<br />/ op1/op2 除<br />
<br />% op1%op2 取模(求余)</p>
<p>Java对 加 运 算 符 进 行 了 扩 展 ,使 它 能 够 进 行 字 符 串 的 连 接 ,如 &#8220;abc&#8221;+&#8221;de&#8221;,得 到 串 &#8220;abcde&#8221;。 我<br />
<br />们 将 在 第 七 章 中 讲 解 。</p>
<p>与 C、 C++不 同 ,对 取 模 运 算 符 %来 说 ,其 操 作 数 可 以 为 浮 点 数 , 如 37.2%10=7.2。</p>
<p>二 、 一 元 算 术 运 算 符 ,如 下 表 所 示 :</p>
<p>运算符 用法 描述<br />
<br />+ +op 正值<br />
<br />- -op 负值<br />
<br />++ ++op,op++ 加1<br />
<br />&#8211; &#8211;op,op&#8211; 减1</p>
<p>i++与 ++i的 区 别</p>
<p>i++在 使 用 i之 后 ,使 i的 值 加 1,因 此 执 行 完 i++后 ,整 个 表 达 式 的 值 为 i,而 i的 值 变 为 i+1。</p>
<p>++i在 使 用 i之 前 ,使 i的 值 加 1,因 此 执 行 完 ++i后 ,整 个 表 达 式 和 i的 值 均 为 i+1。</p>
<p>对 i&#8211;与 &#8211;i同 样 。</p>
<p>例 3.1.下 面 的 例 子 说 明 了 算 术 运 算 符 的 使 用</p>
<p>public class ArithmaticOp{<br />
<br />public static void main( String args[] ){<br />
<br />int a=5+4; //a=9<br />
<br />int b=a*2; //b=18<br />
<br />int c=b/4; //c=4<br />
<br />int d=b-c; //d=14<br />
<br />int e=-d; //e=-14<br />
<br />int f=e%4; //f=-2<br />
<br />double g=18.4;<br />
<br />double h=g%4; //h=2.4<br />
<br />int i=3;<br />
<br />int j=i++; //i=4,j=3<br />
<br />int k=++i; //i=5,k=5<br />
<br />System.out.println(&#8220;a = &#8220;+a);<br />
<br />System.out.println(&#8220;b = &#8220;+b);<br />
<br />System.out.println(&#8220;c = &#8220;+c);<br />
<br />System.out.println(&#8220;d = &#8220;+d);<br />
<br />System.out.println(&#8220;e = &#8220;+e);<br />
<br />System.out.println(&#8220;f = &#8220;+f);<br />
<br />System.out.println(&#8220;g = &#8220;+g);<br />
<br />System.out.println(&#8220;h = &#8220;+h);<br />
<br />System.out.println(&#8220;i = &#8220;+i);<br />
<br />System.out.println(&#8220;j = &#8220;+j);<br />
<br />System.out.println(&#8220;k = &#8220;+k);<br />
<br />}<br />
<br />}<br />
<br />其结果为:<br />
<br />C:＞java ArithmaticOp<br />
<br />a = 9<br />
<br />b = 18<br />
<br />c = 4<br />
<br />d = 14<br />
<br />e = -14<br />
<br />f = -2<br />
<br />g = 18.4<br />
<br />h = 2.4<br />
<br />i = 5<br />
<br />j = 3<br />
<br />k = 5</p>
<p>§ 3.2关 系 运 算 符</p>
<p>关 系 运 算 符 用 来 比 较 两 个 值 ,返 回 布 尔 类 型 的 值 true或 false。 关 系 运 算 符 都 是 二 元 运 算<br />
<br />符 ,如 下 表 所 示 :</p>
<p>运算符 用法 返回true的情况<br />
<br />＞ op1＞op2 op1大于op2<br />
<br />＞+ op1＞=op2 op1大于或等于op2<br />
<br />＜ op1＜op2 op1小于op2<br />
<br />＜= op1＜=op2 op1小于或等于op2<br />
<br />== op1==op2 op1与op2相等<br />
<br />!= op1!=op2 op1与op2不等</p>
<p>Java中 ,任 何 数 据 类 型 的 数 据 (包 括 基 本 类 型 和 组 合 类 型 )都 可 以 通 过 ==或 !=来 比 较 是 否<br />
<br />相 等 (这 与 C、 C++不 同 )。</p>
<p>关 系 运 算 的 结 果 返 回 true或 false,而 不 是 C、 C++中 的 1或 0。</p>
<p>关 系 运 算 符 常 与 布 尔 逻 辑 运 算 符 一 起 使 用 ,作 为 流 控 制 语 句 的 判 断 条 件 。 如</p>
<p>if( a＞b &amp;amp;&amp;amp; b==c)</p>
<p>§ 3.3布 尔 逻 辑 运 算 符</p>
<p>布 尔 逻 辑 运 算 符 进 行 布 尔 逻 辑 运 算 ,如 下 表 所 示 :</p>
<p>op1 op2 op1&amp;amp;&amp;amp;op2 op1||op2 !op1<br />
<br />false false false false true<br />
<br />false true false true true<br />
<br />true false false true false<br />
<br />true true true true false<br />
<br />}@@@<br />
<br />·&amp;amp;&amp;amp;、‖　为二元运算符,实现逻辑与、逻辑或。<br />
<br />·! 为一元运算符,实现逻辑非。<br />
<br />·对于布尔逻辑运算,先求出运算符左边的表达式的值,对或运算如果为true,则整个表<br />
<br />达式的结果为true,不必对运算符右边的表达式再进行运算;同样,对与运算,如果左边表达式<br />
<br />的值为false,则不必对右边的表达式求值,整个表达式的结果为false。<br />
<br />下面的例子说明了关系运算符和布尔逻辑运算符的使用。<br />
<br />@@@[<br />
<br />public class RelationAndConditionOp{<br />
<br />public static void main( String args[] ){<br />
<br />int a=25,b=3;<br />
<br />boolean d=a＜b; //d=false<br />
<br />System.out.println(&#8220;a＜b = &#8220;+d);<br />
<br />int e=3;<br />
<br />if(e!=0 &amp;amp;&amp;amp; a/e＞5)<br />
<br />System.out.println(&#8220;a/e = &#8220;+a/e);<br />
<br />int f=0;<br />
<br />if(f!=0 &amp;amp;&amp;amp; a/f＞5)<br />
<br />System.out.println(&#8220;a/f = &#8220;+a/f);<br />
<br />else<br />
<br />System.out.println(&#8220;f = &#8220;+f);<br />
<br />}<br />
<br />}<br />
<br />其运行结果为:<br />
<br />C:＞java RelationAndConditionOp<br />
<br />a＜b = false<br />
<br />a/e = 8<br />
<br />f = 0</p>
<p>注 意 :上 例 中 ,第 二 个 if语 句 在 运 行 时 不 会 发 生 除 0溢 出 的 错 误 ,因 为 e!=0为 false,所 以 就 不 需<br />
<br />要 对 a/e进 行 运 算 。</p>
<p>§ 3.4位 运 算 符</p>
<p>位 运 算 符 用 来 对 二 进 制 位 进 行 操 作 ,Java中 提 供 了 如 下 表 所 示 的 位 运 算 符 :</p>
<p>位 运 算 符 中 ,除 　 ～ 　 以 外 ,其 余 均 为 二 元 运 算 符 。</p>
<p>操 作 数 只 能 为 整 型 和 字 符 型 数 据 。</p>
<p>3.4.1补 码</p>
<p>Java使 用 补 码 来 表 示 二 进 制 数 ,在 补 码 表 示 中 ,最 高 位 为 符 号 位 ,正 数 的 符 号 位 为 0,负 数<br />
<br />为 1。 补 码 的 规 定 如 下 :</p>
<p>对 正 数 来 说 ,最 高 位 为 0,其 余 各 位 代 表 数 值 本 身 (以 二 进 制 表 示 ),如 +42的 补 码 为<br />
<br />00101010。</p>
<p>对 负 数 而 言 ,把 该 数 绝 对 值 的 补 码 按 位 取 反 ,然 后 对 整 个 数 加 1,即 得 该 数 的 补 码 。 如<br />
<br />-42的 补 码 为 11010110 (00101010 按 位 取 反 11010101 +1 11010110 )</p>
<p>用 补 码 来 表 示 数 ,0的 补 码 是 唯 一 的 ,都 为 00000000。 (而 在 原 码 ,反 码 表 示 中 ,+0和 -0的 表 示<br />
<br />是 不 唯 一 的 ,可 参 见 相 应 的 书 籍 )。 而 且 可 以 用 111111表 示 -1的 补 码 (这 也 是 补 码 与 原 码 和 反<br />
<br />码 的 区 别 )。</p>
<p>3.4.2按 位 取 反 运 算 符 　 ～</p>
<p>～ 　 是 一 元 运 算 法 ,对 数 据 的 每 个 二 进 制 位 取 反 ,即 把 1变 为 0,把 0变 为 1。</p>
<p>例 如 :</p>
<p>0010101</p>
<p>～</p>
<p>1101010</p>
<p>注 意 ,～ 运 算 符 与 &#8211; 运 算 符 不 同 ,～ 21≠ -21。</p>
<p>3.4.3按 位 与 运 算 符 &amp;amp;</p>
<p>参 与 运 算 的 两 个 值 ,如 果 两 个 相 应 位 都 为 1,则 该 位 的 结 果 为 1,否 则 为 0。 即 :</p>
<p>0 &amp;amp; 0 = 0,0 &amp;amp;1 = 0,1 &amp;amp; 0 = 0,1 &amp;amp; 1 = 1<br />
</font></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zye.me/2011/07/27201.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java网络编程</title>
		<link>http://blog.zye.me/2011/07/38146.html</link>
		<comments>http://blog.zye.me/2011/07/38146.html#comments</comments>
		<pubDate>Wed, 20 Jul 2011 02:27:28 +0000</pubDate>
		<dc:creator>yezheng</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[信息检索]]></category>
		<category><![CDATA[网络编程]]></category>

		<guid isPermaLink="false">http://www.5yiso.cn/2008/07/38146.html</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://blog.zye.me/2011/07/38146.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java List转化为数组&#8212;备忘</title>
		<link>http://blog.zye.me/2011/07/36049.html</link>
		<comments>http://blog.zye.me/2011/07/36049.html#comments</comments>
		<pubDate>Sun, 17 Jul 2011 02:28:55 +0000</pubDate>
		<dc:creator>yezheng</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[ArrayList]]></category>
		<category><![CDATA[List]]></category>

		<guid isPermaLink="false">http://www.5yiso.cn/2008/07/36049.html</guid>
		<description><![CDATA[ArrayList&#38;amp;lt;String&#38;amp;gt; list = new ArrayList&#38;amp;lt;String&#38;amp;gt;(); list.add(&#8220;1&#8243;); list.add(&#8220;2&#8243;); list.add(&#8220;3&#8243;); //该语句是关键，new String[0]实际上是告诉系统list中是String类型的数据，数组无所谓，不必与list.size(）相同 String texts[] = (String [])list.toArray(new String[0]); if(texts == null){ log.info(&#8220;texts is null&#8221;); }else{ log.info(&#8220;len:&#8221; + texts.length); }]]></description>
			<content:encoded><![CDATA[<p>    ArrayList&amp;amp;lt;String&amp;amp;gt; list = new ArrayList&amp;amp;lt;String&amp;amp;gt;();<br />        list.add(&#8220;1&#8243;);<br />        list.add(&#8220;2&#8243;);<br />        list.add(&#8220;3&#8243;);<br />        //该语句是关键，new String[0]实际上是告诉系统list中是String类型的数据，数组无所谓，不必与list.size(）相同<br />        String texts[] = (String [])list.toArray(new String[0]);<br />        if(texts == null){<br />            log.info(&#8220;texts is null&#8221;);<br />        }else{<br />            log.info(&#8220;len:&#8221; + texts.length);<br />        }</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zye.me/2011/07/36049.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

