<font face="宋体" size="3">
</font><p><span>判断一个字符串是否是回文。回文是指:字符串从左向右读与从右向左度是一样的。</span></p><font face="宋体" size="3">
</font><p><span lang="EN-US"><font face="Calibri">import java.util.Arrays;</font></span></p><font face="宋体" size="3">
</font><p><span lang="EN-US"><font face="Calibri">public class ExamDemo {</font></span></p><font face="宋体" size="3">
</font><p><span lang="EN-US"><font face="Calibri"><span> </span>public
static void main(String[] args){</font></span></p><font face="宋体" size="3">
</font><p><span lang="EN-US"><font face="Calibri"><span> </span>String
s = args[0];</font></span></p><font face="宋体" size="3">
</font><p><span lang="EN-US"><font face="Calibri"><span> </span>char[]
str = s.toCharArray();</font></span></p><font face="宋体" size="3">
</font><p><font face="Calibri"><span lang="EN-US"><span> </span></span><span lang="NO-BOK">int i;</span></font></p><font face="宋体" size="3">
</font><p><span lang="NO-BOK"><font face="Calibri"><span> </span>for (i = 0; i < str.length / 2; i++){</font></span></p><font face="宋体" size="3">
</font><p><font face="Calibri"><span lang="NO-BOK"><span> </span></span><span lang="EN-US">if
(str[i] != str[str.length - i - 1])</span></font></p><font face="宋体" size="3">
</font><p><span lang="EN-US"><font face="Calibri"><span> </span>break;</font></span></p><font face="宋体" size="3">
</font><p><span lang="EN-US"><font face="Calibri"><span> </span>}</font></span></p><font face="宋体" size="3">
</font><p><span lang="EN-US"><font face="Calibri"><span> </span>if
(i == str.length / 2)</font></span></p><font face="宋体" size="3">
</font><p><span lang="EN-US"><font face="Calibri"><span> </span>System.out.println("</font></span><span>字符串</span><span lang="EN-US"><font face="Calibri">" + args[0] + "</font></span><span>是回文</span><span lang="EN-US"><font face="Calibri">");</font></span></p><font face="宋体" size="3">
</font><p><span lang="EN-US"><font face="Calibri"><span> </span>else</font></span></p><font face="宋体" size="3">
</font><p><span lang="EN-US"><font face="Calibri"><span> </span>System.out.println("</font></span><span>字符串</span><span lang="EN-US"><font face="Calibri">" + args[0] + "</font></span><span>不是回文</span><span lang="EN-US"><font face="Calibri">");</font></span></p><font face="宋体" size="3">
</font><p><span lang="EN-US"><font face="Calibri"><span> </span>}</font></span></p><font face="宋体" size="3">
</font><p><span lang="EN-US"><font face="Calibri">}</font></span></p><font face="宋体" size="3">
</font><p><br></p>