判断字符串是不是回文

    技术2022-05-19  19

    public class Palindrome{     public boolean isPalindrome(String[] str) {          int len = str.length;          boolean b = false;          for(int i = 0; i <= len/2; i++ ) {             if(str[i] != str[len-i-1]) {                 break;             } else {                 b = true;             }                       }          return b;     }         public static void main(String[] args) {          String[] str = {"L","V","E","V","L"};                   if(new Palindrome().isPalindrome(str) ) {                 System.out.println("该字符串是回文字符串!");          } else {                 System.out.println("该字符串不是回文字符串!");            }                   } }

    http://hujinfan.javaeye.com/blog/761518


    最新回复(0)