Write a Java program that checks whether a given string is a palindrome or not.
/*
Write a Java program that checks whether a given string is a palindrome
or not.
Ex: MADAM is a palindrome?
*/
import java.util.*;
class Nineteen
{
public static void main(String arg[])
{
String str, r = "";
Scanner in = new Scanner(System.in);
System.out.print("\n Enter String : ");
str = in.nextLine();
for (int i=str.length()-1 ; i>=0 ; i--)
{
r = r + str.charAt(i);
}
if (str.equals(r))
{
System.out.println("'" + str + "' Is A Palindrome");
}
else
{
System.out.println("'" + str + "' Is Not A Palindrome");
}
}
}
More Information on our channel Programmer Community
please like , share and subscribe to get notifications of new videos....
To understand this program video will coming soon on our you tube channel
Comments
Post a Comment