How to find a String is Palindrome or Not

How to find a String is Palindrome or Not
SOURCE : Pailaindrome.java

public class Pailaindrome {

public static boolean isplaind(String name) {

boolean ispln = true;
int j = name.length() - 1;
for (int i = 0; i < name.length(); i++, j--) {
if (name.charAt(i) != name.charAt(j)) {
ispln = false;
break;
}
}

return ispln;

}

public static void main(String[] args) {

String name = "DALAD";
isplaind(name);

System.out.println(isplaind(name));
}
}

INPUT

"DALAD"



OUTPUT

true






Sandeep Kumar D

Hi, I have written and developed this post so that most of people will be benefited. I'm committed to provide easy and in-depth tutorials on various technologies.I hope it will help you a lot.

- Sandeep Kumar D

Follow Me @Google+




SHARE

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment