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. Could you please explain how to define our own val
View Tutorial          By: xxxxx at 2010-06-30 06:41:14

2. hi.I am new in j2me and really want to learn more
View Tutorial          By: vinoth kumar. A at 2012-10-26 05:20:31

3. Really nice tutorial for memset(), memcopy() and m
View Tutorial          By: Hitesh Kumar at 2012-09-03 09:16:32

4. the way of explanation is really good. there is a
View Tutorial          By: Arul at 2009-01-09 00:13:46

5. Thanks for the help, however I am having some diff
View Tutorial          By: Andrew at 2008-09-30 14:51:14

6. very nice..thank you so much.all the concepts are
View Tutorial          By: Priya at 2013-01-01 07:39:04

7. Hy gr8 man..!!! It was easy understanding
View Tutorial          By: ahwe at 2010-04-07 02:50:40

8. good explanation
View Tutorial          By: Naresh Kumar at 2010-10-25 00:28:18

9. Nice one. I havn't thought of this before.
View Tutorial          By: Aniket Sawant at 2013-04-09 05:40:58

10. Can anybody help me to send the code for email sen
View Tutorial          By: satendra at 2010-03-23 02:46:18