Comment on Tutorial - Palindrome String in Java By Grant Braught



Comment Added by : Sandhya

Comment Added at : 2012-06-21 06:08:25

Comment on Tutorial : Palindrome String in Java By Grant Braught
The smiple easy and best way is :)
------------------------------------------------
import java.util.Scanner;
public class Palindrome {
static String str2 = "";
static String comString;
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
String enteredString = s.next();
comString = enteredString;
int stringLength = enteredString.length();
for (int i = stringLength - 1; i >= 0; i--) {
char currentChar = enteredString.charAt(i);
String str1 = Character.toString(currentChar);
str2 = str2.concat(str1);
}
if (str2.equals(comString)) {
System.out.println("Is Pallandrome");
} else {
System.out.println("Not a Pallandrome");
}
}
}


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. hi RAMLAK i am akankshain and getting these erro
View Tutorial          By: akanksha at 2011-12-06 10:15:47

2. hello

my problem is how to intrega

View Tutorial          By: mihir patel at 2013-11-28 18:10:04

3. @ Qui:

You can set the CSS Style:
View Tutorial          By: hache at 2010-06-22 02:02:56

4. Thanks, very helpful. Worked perfectly.
View Tutorial          By: Bob Knob at 2011-07-27 18:22:18

5. How could i read a file from my ftp server . sugge
View Tutorial          By: Dinshaw at 2015-02-06 07:22:03

6. it giving me error in following statment (using Li
View Tutorial          By: Priyadarsan at 2007-11-27 22:31:56

7. Hi!
Any body have code for recieving sms fr

View Tutorial          By: Haseeb at 2009-07-01 04:59:13

8. thank u. it is very useful for users
View Tutorial          By: c.balasubramani at 2008-09-24 03:55:47

9. Hi! Thanks for the examples posted here...it reall
View Tutorial          By: creece at 2009-01-23 17:28:33

10. hi, IF ANY ONE REALLY INTRESTED TO RUN THIS PROGRA
View Tutorial          By: sunil kumar sahu at 2010-10-09 11:50:56