Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Method To Check If The Given String Is Palindrom Or Not.

DZone's Guide to

Method To Check If The Given String Is Palindrom Or Not.

·
Free Resource
// Checks if the given string is a palindrome/not.


public static boolean isPalindrome(final String text) {
  for (int i = 0, j = text.length() - 1; i < text.length() / 2; i++, j--) {
     if (text.charAt(i) != text.charAt(j)) {
	return false;
     }
  }
  return true;
}
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}