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



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. short and very clear
View Tutorial          By: ramesh at 2009-07-22 22:27:25

2. i should say, a lot of thank you because of this s
View Tutorial          By: merven at 2009-03-17 09:45:39

3. how to use isset keyword with multidimensional arr
View Tutorial          By: mehul at 2015-01-19 23:47:02

4. this site is so good...... How can we create a mp4
View Tutorial          By: vikram raj at 2011-01-05 01:03:07

5. very good and very simple for beginers
View Tutorial          By: Biju Thomas at 2010-08-17 08:09:30

6. sir, could you please tell me about minimum and ma
View Tutorial          By: priya dwivedi at 2012-01-04 15:01:03

7. nice one dear
View Tutorial          By: pradeep at 2010-02-15 07:00:35

8. Thanks a ton! :)
View Tutorial          By: Prateek at 2015-03-12 11:40:08

9. I am getting this exeception when trying to send m
View Tutorial          By: praveen at 2012-12-27 11:15:14

10. Hi thanks for the example for overriding toString(
View Tutorial          By: Reshma at 2011-05-11 10:46:08