Java Program to Check Palindrome

Palindrome Strings are that strings which have same word if we change their character in reverse order . So it does'n matter if we reverse them ,their word remain same . 

Source Code


package com.ancodingpoint.www;
import java.util.Scanner;

public class Palindrome{
public static void main(String[] args) {
    Scanner input = new Scanner (System.in);
    String user_story = "";
    String pal_string = "";
    int length ;
    System.out.println(" Enter Your Stroy to Check its Palindrome ");
    user_story = input.nextLine();
    length = user_story.length();
    for (int i = length-1;i>=0;i--)
    
        pal_string = pal_string + user_story.charAt(i);
        if (user_story.equals(pal_string))
        System.out.println(" Your Story is Palindrome ");
       else
       System.out.println(" Your Story is Not Palindrome ");     
    
            }   
                }

Output of the Program

Palindrome String

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment