Udemy coupon 100 off 2017 ::Udemy coupon code free :: Get 100+ Free Udemy coupons Here

String given as command line argument is Palindrome or not



Check String given as command line argument is Palindrome or not?


Out Put is as following :


import java.util.*;

class Palindrome
{
   public static void main(String args[])
   {
      String originalString, reverseString="";

      originalString = args[0];

      int length = originalString.length();

      for ( int i = length - 1 ; i >= 0 ; i-- )
         reverseString = reverseString + originalString.charAt(i);

      if (originalString.equals(reverseString))
         System.out.println("Entered string is a palindrome.");
      else
         System.out.println("Entered string is not a palindrome.");

   }
}
  • Save the file with name Palindrome.java 
  • Compile with: javac Palindrome.java
  • Run with: java Palindrome malayalam
  • Run with: java Palindrome madam
  • Run with: java Palindrome Java
  • Run with: java Palindrome good

1 comment: