Results 1 to 3 of 3

Thread: Palindrome

  1. #1
    Join Date
    Apr 2011
    Rep Power

    Default Palindrome

    Suppose I have a string say :-

    String S='Madam'; or String S="Hello";

    I need to find out whether the string is palindrome or not. Can someone suggest me the program. Also for palindrome of numbers.

  2. #2
    dlorde is offline Senior Member
    Join Date
    Jun 2008
    Rep Power


    You can tell a palindrome by reversing the text and comparing it with the original. For numbers, just convert them to Strings first:
    Java Code:
    boolean isPalindrome = text.equals(new StringBuilder(text).reverse().toString());

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power


    Smells like a homework assignment. What have you tried? Where are you stuck?
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

Similar Threads

  1. Palindrome program help
    By Nel in forum New To Java
    Replies: 1
    Last Post: 03-03-2011, 04:49 AM
  2. Palindrome question
    By luke in forum New To Java
    Replies: 20
    Last Post: 10-02-2010, 02:17 AM
  3. Palindrome
    By pinkdreammsss in forum Java Applets
    Replies: 8
    Last Post: 05-04-2010, 04:59 PM
  4. HELP...Palindrome
    By d7o0om in forum New To Java
    Replies: 12
    Last Post: 11-13-2009, 04:32 AM
  5. Palindrome Test
    By Ada in forum New To Java
    Replies: 1
    Last Post: 05-26-2007, 02:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts