Completely Free .NET word API

Resources » Code Snippets » General

A simple program to check string palindrome in java

Updated: Category: General
Author: Member Level: GoldPoints: 5

In this article, you will know a simple program to check string palindrome in java. Learn how to handle a simple program to check string palindrome in java.

A simple program to check string palindrome in java

This code uses a for loop to reverse a string not the reverse() method of Java. Then it compares the reversed string with the actual string using equals() method.

Class Palindrome
public static void main(String args[])
String s="malayalam";
int i;
int n=s.length();
String str="";
System.out.println(s+ "is palindrome");
System.out.println(s+ "is not a palindrome");

Did you like this resource? Share it with your friends and show your love!

Responses to "A simple program to check string palindrome in java"
Author: palla subramanyam  25 Jan 2012   Member Level: Bronze   Points : 2
The more simple and efficient one is

public class Palindrome {
static public String pal(String str, int i, int j){
if(str.length()/2 != i)
return "String is Not palaindrome";

return "String is palaindrome";
public static void main(String[] args) {
String str = args[0];

Guest Author: vetrivel   04 Aug 2012
very easy to learn

Author: kritika  17 Aug 2014   Member Level: Bronze   Points : 0
I need a simple program to check whether a string or number is a palindrome or not.without using scanner.


Post Comment:

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)

    Type the numbers and letters shown on the left.

    Submit Article     Return to Article Index
    Subscribe to Subscribers
    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India