Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Java program to check whether the given string is a palindrome or not

public static void main(String[] args) throws ParseException {
    String word;
    Scanner in = new Scanner(System.in);
    System.out.println("Enter a string to check if it is a palindrome");
    word = in.nextLine();
    System.out.println(palindromeChecker(word));
}
public static String palindromeChecker(String word){
    int length = word.length();
    String reverse="";
    for ( int i = length - 1 ; i >= 0 ; i-- )
        reverse = reverse + word.charAt(i);
    if (word.equals(reverse))
        return "Palindrome";
    else
        return "Not a Palindrome";
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Java #program #check #string #palindrome
ADD COMMENT
Topic
Name
8+6 =