I'm having trouble returning true and false things in java.
Expand|Select|Wrap|Line Numbers
- import java.io.*;
- public class StringUtil
- {
- public static void main(String args[]) throws IOException
- {
- BufferedReader reverseString = new BufferedReader(new InputStreamReader(System.in));
- String revString;
- BufferedReader palindromeString = new BufferedReader(new InputStreamReader(System.in));
- String palString;
- BufferedReader pigLatinString = new BufferedReader(new InputStreamReader(System.in));
- String plString;
- BufferedReader shortHandString = new BufferedReader(new InputStreamReader(System.in));
- String shString;
- int i = 0;
- int indexPalString = 0;
- System.out.println("Enter a potential Palindrome:");
- palString = palindromeString.readLine();
- indexPalString = palString.length() - 1;
- for(i = 0; i <= indexPalString; i++)
- {
- if (palString.charAt(i) == palString.charAt(indexPalString - i))
- {
- return true;
- }
- else{
- return false;
- }
- }
- }
- }
I want it to check whether or not it is a palindrome. It HAS to return true or false.
And is there anyway that i could ignore case, spaces, and punctuation?
Thank You