Side Navigation

X

Palindrome Check

class Solution {
    public static void main(String[] args) {
        String str = "abcdcba";
        System.out.println(methodName(str));
    }
    public static boolean methodName(String str) {
        String nStr = "";
        for(int i = str.length()-1; i>=0; i--){
            nStr = nStr + str.charAt(i);
        }if(nStr.equals(str)){
            return  true;
        }
        return false;
    }
}

 

You May Also Like

Comments

Leave a Comment

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>