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. Your explanation is perfectly clear and not in nee
View Tutorial          By: Percy at 2009-06-08 14:14:39

2. I want to enter data from a textbox to recordstor
View Tutorial          By: Rahul Maurya at 2010-04-10 01:04:51

3. tnx, nice code...
View Tutorial          By: Hansoc at 2009-08-18 00:17:58

4. hi friends,
can i write the same jdbc code

View Tutorial          By: mahesh at 2012-01-05 05:09:38

5. This is so phat. Maybe the best explanation ever t
View Tutorial          By: Devin Prince III at 2010-08-11 10:01:04

6. Apache was failing to deliver php pages that were
View Tutorial          By: Ted at 2010-11-13 08:13:29

7. thanks i am fresher to j2me i understand the conce
View Tutorial          By: anusha at 2010-04-20 00:32:10

8. Thanks so much, this was extremely helpful and rea
View Tutorial          By: gabrielle at 2013-10-04 22:07:17

9. Error loading SolarisSerial: java.lang.Unsatisfied
View Tutorial          By: Sony at 2008-09-10 01:28:52

10. THANK YOU.. YO SO HELP ME :D
View Tutorial          By: xgamer at 2015-08-06 06:45:52