public class Palindrome {
public static void main (String[] args) {
String inStr;
StringBuffer revStr;
// Get the string that is to be checked to
// see if it is a palindrome.
System.out.println("Palindrome Checker...");
System.out.print("Enter a string to check: ");
inStr = Console.in.readLine();
// Create a new StringBuffer object containing the
// same characters as inStr and make revStr
// refer to the new object.
revStr = new StringBuffer(inStr);
// Use the reverse() mutator method of the StringBuffer
// class on the StringBuffer object refered to by revStr.
revStr.reverse();
// Check to see if the inStr and revStr are the same.
// This requires using the .equals() or .equalsIgnoreCase()
// accessor method of the String class. These methods accepts
// a String so the StringBuffer refered to by revSrt must be
// converted to a String...
if (inStr.equalsIgnoreCase(revStr.toString())) {
System.out.println(inStr + " is a palindrome.");
}
else {
System.out.println(inStr + " is not a palindrome.");
}
}
}
I get an error on the following line: inStr = Console.in.readLine();
when I try to compile it..I get the following error:
Palindrome.java:19: cannot resolve symbol
symbol : class in
location: package Console
inStr = Console.in.readLine();
with a little arrow pointing to the "." between the Console and the in.
Yes I am a beginner so the simpler the better,
Thanks
Kim