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 i am sanjay ,
I got the exact difference

View Tutorial          By: Sanjay Patel at 2012-05-06 11:36:00

2. [English]
Good morning ... the question ari

View Tutorial          By: Federico at 2012-06-01 13:55:13

3. This is probably a good java tutorial but it made
View Tutorial          By: lol at 2012-09-15 21:20:09

4. if the number is for exemple 00025478 it return a
View Tutorial          By: ahmed at 2015-02-11 12:02:45

5. i din understand
View Tutorial          By: panda at 2011-07-14 09:35:36

6. good
View Tutorial          By: qwerty at 2014-02-14 07:37:08

7. Hi, thank you so much for this. I am going to give
View Tutorial          By: Eddie at 2011-02-21 14:10:04

8. Hi Avipriya Sharma follow this link for my multi t
View Tutorial          By: Issac at 2011-06-27 00:17:21

9. thanks bro it helped me to answer my facu
View Tutorial          By: kasmin at 2010-01-08 08:11:32

10. thanks
View Tutorial          By: Tejaswini C at 2011-12-23 17:57:03