Here you will get the program for string palindrome in java.
A string is a palindrome if the string is equivalent to its switch. Take underneath models.
Palindrome: asdsa, madam, mother, and so forth.
Not Palindrome: thunder, fish, door, and so forth.
Beneath I have shared a program that will check a string is palindrome in java or not. In this program, I am reversing the string and afterwards comparing the switched string with the original string.
I have utilized Scanner class to peruse the string from console. On the off chance that you find any trouble to comprehend the program, at that point you can ask your inquiries in the remark segment.
Program
import java.util.Scanner;
class StringPalindrome
{
public static void main(String...s)
{
String str1="",str2="";
Scanner sc=new Scanner(System.in);
System.out.println("Enter a string:");
str1=sc.nextLine();
for(int i=str1.length()-1;i>=0;--i)
str2=str2+str1.charAt(i);
if(str1.equals(str2))
System.out.println("String is Palindrome");
else
System.out.println("String is Not Palindrome");
}
}
Output