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



Ask a Question

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,

i have a problem. I have the ti

View Tutorial          By: Felipe at 2010-02-18 05:03:51

2. writa a java program to add two one-dimensional ar
View Tutorial          By: nibedita swain at 2011-08-22 15:23:37

3. Very Good Example Dude!

Note for re

View Tutorial          By: Erwin at 2009-12-06 20:20:24

4. Thanks so much for the tutorial!! Was extremely us
View Tutorial          By: Debarupa at 2012-05-10 20:23:28

5. it s good ,understanding clearly and with out conf
View Tutorial          By: vasudeva kumar at 2012-01-06 14:04:30

6. You are a life saver. My Production website was do
View Tutorial          By: Caricus at 2011-04-07 23:58:37

7. can i get some basic examples of java program
View Tutorial          By: raja at 2013-06-04 10:47:12

8. chat
View Tutorial          By: zahra zare at 2009-05-10 07:07:57

9. Many Thanks.
View Tutorial          By: Kallol Samaddar at 2013-07-11 18:26:06

10. its very helpful and understandable.thanq
View Tutorial          By: Deepika darapaneni at 2012-03-24 14:16:39