Friday, September 21, 2018

Write a program to find that given number or string is palindrome or not.


 
import java.util.Scanner;

public class Program_7 {
    public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);
        String str = scan.next();
        
        String rvs = new StringBuffer(str).reverse().toString();
        
        if(str.equals(rvs)){
            System.out.println("It is palindrome");
        }
        else{
            System.out.println("It is not palindrome");
        }
    }
    
}
  

No comments:

Post a Comment