well to get rid of whitespaces and other ascii characters you can use the String class function "trim"
Or:
Here is the code for removeJunk method, got it from somewhere else.
protected static String removeJunk(String string) {
int i, len = string.length();
StringBuffer dest = new StringBuffer(len);
char c;
for (i = (len - 1); i >= 0; i--) {
c = string.charAt(i);
if (Character.isLetterOrDigit©{
dest.append©;
}
}
return dest.toString();
}
----
In case you get impatient here is the full code of your program
Pallindrome![]()
___________________
If you decide not to look at that code and still trying your code and get stuck let us know. We will sure help you out. Is toLowerCase() working? Also, as String is a class and when you define its object you have to use
String myString = new String("thisString");
However, java lets you define like String myString = "thisString" without errors. So its initializing an object before creating it.
Let us know how it goes.
Bookmarks