class Untitled {
public static void genPal1() {
for( int x = 0; x <301; x++) {
StringBuffer sb;
String s = String.format("%03d", x);
sb = new StringBuffer(s).reverse();
System.out.printf("%s%s%n", s, sb);
}
}
public static void genPal2() {
for (char one = '0'; one < '3'; one ++)
for (char two = '0'; two <= '9'; two ++)
for (char three = '0'; three <= '9'; three ++)
System.out.printf("%c%c%c%c%c%c%n", one, two, three, three, two, one);
}
public static boolean isPal(String s) {
int b = 0, e = s.length()-1;
while ( b < e) {
System.out.println("b = " + b + " e = " + e);
if (s.charAt(b) != s.charAt(e))
return false;
b++; e--;
}
return true;
}
public static void main(String[] args) {
genPal2();
System.out.println("1001001 " + isPal("1001001"));
System.out.println("abba " + isPal("abba"));
System.out.println("abca " + isPal("abca"));
}
}