Write a Java program to check if given String is palindrome or not

Below program illustrates if given String is palindrome or not in Java:

public class PalindromeString {
	public static void main(String[] args) {
		String str = "MADAM";
		boolean isPalindrome = checkIfStringIsPalindrome(str);
		if(isPalindrome) {
			System.out.println(str + " is Palindrome!!");
		} else {
			System.out.println(str + " is not Palindrome!!");
	private static boolean checkIfStringIsPalindrome(String str) {
		char[] chars = str.toCharArray();
		int len = str.length();
		for(int i=0, j=len-1; i<len/2; i++,j--) {
			if(chars[i] != chars[j]) {
				return false;
		return true;

Author: Mahesh

Technical Lead with 10 plus years of experience in developing web applications using Java/J2EE and web technologies. Strong in design and integration problem solving skills. Ability to learn, unlearn and relearn with strong written and verbal communications.