Appear in Online Interview to test your skills and be ready for job!
Twitter Twitter LinkedIn YouTube Google
Be Interview ready ! | Search
Submit content and win cash & prizes monthly.
Winners

Win Prizes

Announcements
Like us on Facebook
Sponsor
Top Codes Author
Thu, 24-Apr-2014 Authors
All Time Authors
Satyapriyanayak
11600
Jayakumars
8120
Niladri.biswas
6000

Latest members | More ...


(Statistics delayed by 5 minutes)

A simple program to check string palindrome in java

Abhisek
Posted by Abhisek under Others on 11/26/2009 1:00:56 AM | Views : 12253 | Status : [Member]

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="";
for(i=n-1;i>=0;i--)
str=str+s.charAt(i);
if(str.equals(s))
System.out.println(s+ "is palindrome");
else
System.out.println(s+ "is not a palindrome");
}
}


Abhisek Panda
Found interesting? Add this to:



Comments or Responses


Login to post response.

Comments / Responses
Select text & click toolbar to format. Formatting appears in viewmode only. HTML Tags are not allowed.
Bold Italic Underline Paragraph Title Code  Link 
 Wait ... Processing ..... please wait.