WHAT'S NEW?
Loading...

String Palindrome program in Java

import java.util.*;
import java.lang.*;

class palindrome
{
 public static void main(String args[])
 {
   Scanner din=new Scanner(System.in);
   
   System.out.println("Enter a string: ");
   String str=din.next();

   String rstr=new StringBuffer(str).reverse().toString();
  
   if(str.equals(rstr))
    System.out.println("Enterred string is palindrome.");
   else
    System.out.println("Enterred string isnt a palindrome string.");
 
 }
}
Post a Comment