Hi .. Provably I'm setting this up the wrong way in Netbeans.. I open a new projetc and use the default main...then open a new empty java file and type my code , when I run this it runs fine but it doesn't ask for input !
import java.io.*;
public class Palindrome
{
static boolean CheckPalindrome(String s, int leftSide, int rightSide)
{
if (rightSide <= leftSide)
return true;
else if (s.charAt(leftSide) != s.charAt(rightSide))
return false;
else
return CheckPalindrome(s,leftSide+1,rightSide-1);
}
public static void main(String[] args) throws IOException
{
String str;
int n;
InputStreamReader inStream = new InputStreamReader( System.in );
BufferedReader stdin = new BufferedReader( inStream );
System.out.print("Please enter any string: ");
str = stdin.readLine();
int lastPosition = str.length()-1;
boolean result = CheckPalindrome(str , 0, lastPosition);
if (result)
System.out.println("The string \""+str+"\" is a palindrome ");
else
System.out.println("The string \""+str+"\" is not a palindrome ");
}
}