Sunday, May 13, 2012

Java Program for finding Palindrome


Just follow the program to find Palindrome  in java:


import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Palindrome {


    public static void main(String[] args) throws Exception {


   BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 
    String s1 = new String();
    
    s1 =br.readLine();
    
    s1 = s1.toLowerCase();
    String s2 = new StringBuffer(s1).reverse().toString();
    
    if(s1.equals(s2)){    
    System.out.println("Palindrome");
    }else 
        System.out.println("Not Palindrome");
     }
}

 

Programming, Data Structures & Algorithms Copyright © 2011 -- Template created by JAK -- Powered by Blogger