import java.util.*;
public class Main {
public static boolean main(String[] args) {
// from Ratan Kadam
String str = "abbbba";
char[] chararr = str.toCharArray();
boolean bool = true;
int Strlen = str.length();
int endChar = Strlen -1;
for (int i = 0; i < Strlen / 2; i++) {
// only till half the string need to be process / this will work for even and odd length
if (chararr[i] != chararr[endChar]) {
System.out.print("Not a Palindrom");
return false;
}
endChar --;
}
System.out.print("String is Palindrom..");
return true;
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.