hello. can anyone help me? this is kind of a class project, and I'm stuck. here's my program
import java.io.*;
public class lab16B
{
public static void main (String args[]) throws IOException
{
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter a string ===> ");
Palindrome p = new Palindrome(input.readLine());
p.displayData();
}
}
class Palindrome
{
private String s;
private boolean palindrome;
private boolean isPal()
{
String s2="";
int n = s.length()-1;
for(int k = n;k >= 0;k--)
s2+=s.charAt(k);
System.out.print(""+s2);
if(s.equals(s2))
return true;
else
return false;
}
public Palindrome(String s)
{
this.s=s;
}
public void displayData()
{
System.out.print(""+s);
System.out.print("\n");
System.out.print(""+palindrome);
}
}
The problem is that whenever I run it, and whatever the string I input, it keeps giving me "false". please help me