public class PalindromeOfString { public void reverseOfString(String string) { String reverseString = ""; int lenth = string.length(); for (int i = lenth - 1; i >= 0; i--) { reverseString = reverseString + string.charAt(i); } if (reverseString.equals(string)) { System.out.println("string is a palindrome."); } else { System.out.println("string is not a palindrome."); } } public static void main(String args[]){ PalindromeOfString r = new PalindromeOfString(); r.reverseOfString("tat"); } }