github: Palindrome.java
A few good ways to remove space from a string.
private static String removeSpace(String aword) {
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < aword.length(); i++) {
if (aword.charAt(i) != ' ')) {
buffer.append(aword.charAt(i));
}
}
return buffer.toString();
}
//Removing all white spaces from s1 and s2
String copyOfs1 = s1.replaceAll(
"\\s"
,
""
);
String copyOfs2 = s2.replaceAll(
"\\s"
,
""
);