| 
 
| 本帖最后由 一顿一只牛 于 2014-8-7 10:43 编辑 
 public class Text4 {
 public static void main(String[] args){
 String str = "abda";
 com(str);
 }
 
 @SuppressWarnings("unused")
 public static void com(String str){
 int count = (str.length()-1)/2;   //判断次数为x<=count
 boolean result = true;
 
 for(int x=0;x<=count;x++){
 
 if(str.charAt(x)!=str.charAt(str.length()-1-x)){
 result = false;
 //break;
 }
 break;
 }
 if(result){
 System.out.println(str+" 是对称字符串!");
 }
 else
 System.out.println(str+" 不是对称字符串!");
 
 }
 }
 为什么输入字符串abda  得到的输出是对称的呀。
 求大神解答。
 | 
 |