How to find the palindrome words in String using Java ?

Palindrome is nothing it is just same reverse of string like example : MADAM it is a palindrome using Array. Below example will show you how to find Palindrome words in string.

Find Palindrome Words in String

import java.util.Scanner;
class palidrom
{
public static void main(String arg[])
{
String rev=””;
System.out.println(“Enter any String and check its palindrome or Not”);
Scanner sc=new Scanner(System.in);
String str=sc.nextLine(); // String store
int s=str.length(); // String length store in integer
for(int i=s-1;i>=0;i–){ //example string madam int length =5
rev=rev+str.charAt(i);
}
if(str.equals(rev))
{
System.out.println(str + ” is a palindrome”);
}
else
{
System.out.println(str + ” is not palindrome”);
}}}

If you have any issue comment us in the comment box. Our experts will reply you as soon as possible.

Amandeep kaur: Amandeep Kaur is passionate about programming and is working on Android development from her school days. She has worked on many open source projects and now part of Hoodu Digital solutions as a Android developer.