Basically, this program checks if a word (String s) is a palindrome and prints out "true" if it is and "false" if it isn't.
I am currently getting three errors: "unexpected type" at line 17, "incompatible types" at lines 30 and 32.
/**
* @(#)palindrome.java
*
*
* @author
* @version 1.00 2009/12/10
*/
import java.util.*;
public class palindrome {
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
if (check(s) = true)
{
System.out.println("\ntrue");
}
else
{
System.out.println("\nfalse");
}
}
public static boolean check(String s)
{
String t, r;
for (int i = s.length(); i = 0; i--)
{
t = s.charAt(i);
r = t + r;
}
if (r == s)
{
return true;
}
else
{
return false;
}
}
}