Results 1 to 3 of 3

Thread: Palindrome

  1. #1
    Join Date
    Apr 2011
    Posts
    16
    Rep Power
    0

    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
    Posts
    339
    Rep Power
    7

    Default

    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 online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,987
    Rep Power
    9

    Default

    Smells like a homework assignment. What have you tried? Where are you stuck?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

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