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. Thank you......
View Tutorial          By: Suvadip at 2013-04-19 05:11:51

2. i am using tata photon+ modem ,so which csca numb
View Tutorial          By: ganesh at 2011-01-30 12:11:01

3. The example shown in this article uses 8-bit opera
View Tutorial          By: wisnu at 2012-10-04 05:11:51

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

5. i want full of information abt java
View Tutorial          By: sagar at 2010-08-23 06:42:40

6. Legend. Worked first time!
View Tutorial          By: Luke at 2014-12-19 10:10:00

7. Good examples for beginners.
View Tutorial          By: Sagar at 2009-10-16 01:04:46

8. Answer for Comment 4 :

" n=n++

View Tutorial          By: NewB_of_java at 2012-02-16 16:52:05

9. excellent for a beginer in inet address ...
View Tutorial          By: Tony at 2009-08-13 22:39:48

10. be very careful. use of put (or any method inheri
View Tutorial          By: d at 2009-10-14 09:55:23