public class palindrome{
  public static void main(String[] args){
    String str1 = "eye",str2 = "bye";
    System.out.println("palindrome detection");
    System.out.println(str1 + " "+ ispalindrome(str1));
    System.out.println(str2 + " "+ispalindrome(str2));
    }
    static boolean ispalindrome(String s){
    int left =0;
    int right = s.length() -1;
    while(left<right){
      if (s.CharAt(left) != s.CharAt(right))
       return false;
       left++;
       right--;
       }
      return true;
    }
}
错误是:cannot resolve symbol就是s.CharAt(left) != s.CharAt(right))这行出问题。谢谢

解决方案 »

  1.   

    charAt
    按规范,方法名都是小写开头的
      

  2.   

    你还是看看 sun 的文档charAt
    public char charAt(int index)
    Returns the char value at the specified index. An index ranges from 0 to length() - 1. The first char value of the sequence is at index 0, the next at index 1, and so on, as for array indexing. 
    If the char value specified by the index is a surrogate, the surrogate value is returned. 
    Specified by:
    charAt in interface CharSequence
    Parameters:
    index - the index of the char value. 
    Returns:
    the char value at the specified index of this string. The first char value is at index 0. 
    Throws: 
    IndexOutOfBoundsException - if the index argument is negative or not less than the length of this string.
      

  3.   

    学习 java 的经常看 帮助文档
    很有帮助的
      

  4.   

    谢谢大家了,可能是书上写错了,我自己刚学java谢谢大家了
      

  5.   

    charAt()
    注意大小写
    java是区别大小写的