The blow program is used to check the string whether it is a palindrome or not. Based on the position of the character in the string we are checking for the same. The simplest way we are following that we are creating one more string from the given string and but in reverse order. After that we are checking that equality of both the strings. import java.util.Scanner; public class StringCheckPalindrome { public static void main(String args[]) { Scanner sc = new Scanner(System.in); try { String str; String rev = ""; System.out.println("Enter a string:"); str = sc.nextLine(); int length = str.length(); for (int i = length - 1; i >= 0; i--) rev = rev + str.charAt(i); if (str.equals(rev)) System.out.println(str + " is a palindrome"); else System.o...
Technology - Marketing - Stocks - Views