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

Popular posts from this blog

Design and Develop a java program to read marks of a student and print the total and average of marks using scanner class.

Write a Java program to convert seconds to hour, minute and seconds.

Write a Java program to print the ascii value of a given character.