Thursday 28 August 2014

Java Program to check Palindrome

Structure of the Problem Requirements 

In this problem we will learn how to check string Palindrome in Java. 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 . Here is the source code of this problem which help you in better understanding.

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
Palindrome String in Java

Share it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

0 comments:

Post a Comment